PHP imagecreatefrompng losing color

风格不统一 提交于 2019-12-23 18:52:27

问题


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...


回答1:


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



来源:https://stackoverflow.com/questions/18845160/php-imagecreatefrompng-losing-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!