Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP imagecreatefrompng losing color

I'm doing a simple load of an image using imagecreatefrompng.

The background of the image is #E5DDBB. Using the code below, it renders the image but the background is now #DED6AD.

http://www.letslogic.com/test.php contains the following:

<img src="images/skins/yoshi/0.png">

<img src="dyn_image.php">

dyn_image.php contains:

<?php

$im = imagecreatefrompng('images/skins/yoshi/0.png');

header("Content-Type: image/png");

imagepng($im);

?>

If you look at the two images that test.php shows, the images are different colours...

like image 216
letslogic.com Avatar asked Jan 19 '26 03:01

letslogic.com


1 Answers

Apparently this is a color profile issue. Something to do with the image being of one color profile, whereas gd only lets you save your image in the one color profile it knows how to save images by which differs from the inputted image's, resulting in the colors looking different.

It seems you are going to need to use imagemagick to not have the colors changed. You should read these:

http://www.zenphoto.org/support/topic.php?id=3582

http://devot-ee.com/add-ons/support/ce-image/viewthread/1085

like image 82
Attila Szeremi Avatar answered Jan 21 '26 07:01

Attila Szeremi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!