Posts Tagged with gd

Displaying 1-2 of 2 results.
Resolved: Skype Ubuntu This software comes from a 3-rd party and may contain non-free components error
posted by admin on January 18, 2017
I am trying to install skype to ubuntu and all methods which I use didn't resolve this error

This software comes from a 3-rd party and may contain non-free components error


In command line I have got error like this

You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
google-chrome-stable : Depends: libpango1.0-0 (>= 1.14.0) but it is not going to be installed
Depends: libappindicator1 but it is not going to be installed
ubuntu-restricted-extras : Depends: ubuntu-restricted-addons but it is not going to be installed
Recommends: ttf-mscorefonts-installer but it is not going to be installed
Recommends: unrar but it is not going to be installed
Recommends: libavcodec-extra
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).



I try to install gdebi installer, and have got error too

sudo apt install gdebi

Error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
gdebi : Depends: gdebi-core (= 0.9.5.7ubuntu1) but it is not going to be installed
Depends: gksu but it is not going to be installed
Depends: gnome-icon-theme but it is not going to be installed
Recommends: libgtk2-perl but it is not going to be installed
google-chrome-stable : Depends: libpango1.0-0 (>= 1.14.0) but it is not going to be installed
Depends: libappindicator1 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Read more
Wiki: PHP Dominant Colour Function with GD Librarywiki
posted by admin on April 13, 2016
Someone asked if it was possible to find the dominant colour (the more frequent colour, in %) of an image.

So I read about the GD PHP Library, which enables image support. I found the interesting function imageColorAt() which the colour of a specific pixel. Hence, my function consists of resizing to a known size, 100 x 100, then looping into each pixel, storing it’s colour into an array, then sorting the array to find the more frequent key.

Here’s the result :

function getDominantColour($image, $type='jpeg') // $type can be gif, jpeg or png
{
// This function needs GD Library enabled

eval('$source = imagecreatefrom' . $type . '("' . $image . '");'); // we load the source image
$source_x = imagesx($source); // source's X
$source_y = imagesy($source); // source's Y
$resized_x = 100; // resized image's X
$resized_y = 100; // resized image's Y
$resized= imagecreatetruecolor($resized_x, $resized_y); // we create a blank 100 x 100 image
imagecopyresampled($resized, $source, 0, 0, 0, 0, $resized_x, $resized_y, $source_x, $source_y); // We then copy and resized the source image into the blank image

// Required vars declaration
$colours = array();
$rgb = '';
$index = array();
for ($x=0; $x<100; $x++) // We loop into the pixels X
{
for ($y=0; $y<100; $y++) // We loop into the pixels Y
{
$rgb = imagecolorat($resized, $x, $y); // get the RGB of the pixel
$index = imagecolorsforindex($resized, $rgb); // Get the RGB Index
$key = 'R' . $index['red'] . 'G' . $index['green'] . 'B' . $index['blue']; // Put it into a string
if (empty($colours[$key])) // If it's the first time this colour is encountered
{
$colours[$key] = 1; // We give it a value of 1
} else { // If it's not the first time it is encountered
$colours[$key]++; // We increment its value
}
}
}
arsort($colours, SORT_NUMERIC); // We then sort the colours array so that the first one is the most frequent one
return key($colours); // we return the most frequent value
}


Working with images sure is fun. Looking forward to have more functions with the GD libraryRead more