gd

Detect main colors in an image with PHP

戏子无情 提交于 2019-11-26 07:22:43
问题 I am trying to replicate the functionality that Dribbble.com does with detecting the predominant colors in an Image. In the image below you can see a screenshot from Dribbble.com that shows the 8 predominant colors in the image to the left. Here is the actual page in the image http://dribbble.com/shots/528033-Fresh-Easy?list=following I need to be able to do this in PHP, once I get the colors I need I will save them to a database so the processing does not need to be run on every page load.

php GD create a transparent png image

柔情痞子 提交于 2019-11-26 06:07:11
问题 I\'m trying to create a transparent png image and layer various other pngs and jpgs to create a final png with transparency. I\'m having trouble creating my initial empty transparent png. It currently has a white background. Can anyone point me in the right direction. This is my code so far... $image = imagecreatetruecolor(485, 500); imagealphablending($image, false); imagesavealpha($image, true); $col=imagecolorallocatealpha($image,255,255,255,127); imagefill($image, 0, 0, $col); /

Compare 2 images in php

て烟熏妆下的殇ゞ 提交于 2019-11-26 05:28:24
问题 Comparing 2 images to see if they are both the same files are easy, threw the files MD5, but is it possible or even plausible to determine if 2 images are same by using PHP GD to get the difference of the two images. If we where to get the difference of the two, and it was all white (id assume white or even black), then we would now know its both the same photo? Also side note: id like to know if its possible to get 2 images of equal size to create an onion skin effect, 50% transparency on 1

imagecreatefrompng() Makes a black background instead of transparent?

戏子无情 提交于 2019-11-26 03:55:27
问题 I make thumbnails using PHP and GD library but my code turn png transparency into a solid black color, Is there a solution to improve my code? this is my php thumbnail maker code: function cropImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[1]; switch($stype) { case \'gif\': $simg = imagecreatefromgif($source); break; case \'jpg\': $simg = imagecreatefromjpeg($source); break; case \'png\': $simg = imagecreatefrompng($source); break; } $dimg =

Creating a thumbnail from an uploaded image

喜欢而已 提交于 2019-11-26 03:09:10
问题 I\'m wanting to create a thumbnail from a user uploaded image so the image doesn\'t look squashed. But also would like a copy of the original image.. So I would like the original image to send the original image to my server and also create a thumb version and send it to my server so I can call each of them for each user that uploads their own image. My user table has 2 tables `user_pic` longblob NOT NULL, `user_pic_small` longblob NOT NULL, I\'m not crash hot with the image side of coding

How do I resize pngs with transparency in PHP?

余生长醉 提交于 2019-11-26 02:20:01
问题 I\'m attempting to resize pngs with transparent backgrounds in PHP and the code samples I\'ve found online don\'t work for me. Here\'s the code I\'m using, advice will be much appreciated! $this->image = imagecreatefrompng($filename); imagesavealpha($this->image, true); $newImage = imagecreatetruecolor($width, $height); // Make a new transparent image and turn off alpha blending to keep the alpha channel $background = imagecolorallocatealpha($newImage, 255, 255, 255, 127);

Efficient JPEG Image Resizing in PHP

梦想与她 提交于 2019-11-26 01:44:11
问题 What\'s the most efficient way to resize large images in PHP? I\'m currently using the GD function imagecopyresampled to take high resolution images, and cleanly resize them down to a size for web viewing (roughly 700 pixels wide by 700 pixels tall). This works great on small (under 2 MB) photos and the entire resize operation takes less than a second on the server. However, the site will eventually service photographers who may be uploading images up to 10 MB in size (or images up to

Can PNG image transparency be preserved when using PHP's GDlib imagecopyresampled?

人走茶凉 提交于 2019-11-26 00:48:01
问题 The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. Even though imagesavealpha is set, something isn\'t quite right. What\'s the best way to preserve the transparency in the resampled image? $uploadTempFile = $myField[ \'tmp_name\' ] list( $uploadWidth, $uploadHeight, $uploadType ) = getimagesize( $uploadTempFile ); $srcImage =

Can PNG image transparency be preserved when using PHP's GDlib imagecopyresampled?

懵懂的女人 提交于 2019-11-25 19:18:25
The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. Even though imagesavealpha is set, something isn't quite right. What's the best way to preserve the transparency in the resampled image? $uploadTempFile = $myField[ 'tmp_name' ] list( $uploadWidth, $uploadHeight, $uploadType ) = getimagesize( $uploadTempFile ); $srcImage = imagecreatefrompng( $uploadTempFile ); imagesavealpha( $targetImage, true ); $targetImage = imagecreatetruecolor(