jpeg ファイルがあり、いくつかのピクセルを特定の色に設定したいとします。jpeg を保存すると、品質を 100 に設定しても色が失われ、新しいピクセルの周りにエイリアシングが見られます。数ピクセル。
// 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 に依存せずにこれを行う方法はありますか?