说我有一个jpeg文件,我想将某些像素设置为某种颜色。当我保存jpeg时,即使将质量设置为100,我也会失去颜色,并且看到我的新像素出现锯齿现象。我知道这是一种有损格式,但我不想重新压缩该图片,只需设置一个几个像素。PHP GD无需重新压缩即可编辑Jpeg
// Create the GD resource
$img = imagecreatefromjpeg($filename);
// Set the first pixel to red
$color = imagecolorallocate($img, 255, 0, 0);
imagesetpixel($img, 0, 0, $color);
// Save the jpeg - is this where I'm wrong? I see the red pixel but it's the wrong color and is blurred.
imagejpeg($img, 'foo.jpg', 100);
// Lossless format works fine, red pixel is bright and accurate.
imagepng($img, 'foo.png');
所以也许GD不是去这里的路?我确实需要改变一些像素的颜色,并且在保存时需要准确。有没有办法做到这一点,而不依赖于GIF,PNG或JPEG2000?
尝试ImageMagick ...它更灵活(基于评论在这里:http://stackoverflow.com/questions/6561345/gd-imagejpeg-compression) – Aziz 2012-04-29 07:02:40