English 中文(简体)
PHP GD Edit Jpeg, 无抑制
原标题:PHP GD Edit Jpeg without re-compressing

Say I have a jpeg file and I want to set some pixels to a certain color. When I save the jpeg, I am losing color and I see aliasing around my new pixels, even if I set quality to 100. I know it s a lossy format, but I don t want to re-compress the picture, just set a few pixels.

// 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 );

因此,要走什么路? 我确实需要改变一些餐厅的颜色,在节省时,需要准确。 如果不依靠全球投资框架、国家投资计划或联合项目2000,是否有办法做到这一点?

最佳回答

As you said yourself, JPEG is a lossy format. It doesn t actually store "pixels" directly. If you make a change to the image, the image has to be re-compressed. There is no way around this.

您的红皮书是“大色”和“蓝色”的,其原因是,日本航天学会如何压缩。 同样,它也不储存粉。 它强调亮度的变化,实际的肤色信息如此重要。

I m not positive, but you may be able to only re-compress the few blocks that are affected by your change. You would not be able to do this with any standard functions, and would have to dig into the format and compression schemes yourself.

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签