开发者

PHP GD: Bad quality on resize?

I dont like the resized image i get out,

imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $n开发者_如何转开发ewheight, $width, $height);

ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext", 100);

I added 100 in ImageJpeg, because i wish to improve the quality, but it didnt get any better.

How can i improve the quality on resized images/thumbnails


Try using imagecopyresampled instead. That does interpolation, which will make things look a lot nicer.


Since PHP 5.5, you can use imagesetinterpolation to determine the way your images are interpolated during transformations (typically, scaling and resampling, but also rotations, etc.).

See http://php.net/manual/en/function.imagesetinterpolation.php

For image downsampling, you probably want to use the IMG_SINC algorithm, it tends to give crisper results. For rotation as well.

For upsampling, IMG_BICUBIC_FIXED, IMG_GENERALIZED_CUBIC and IMG_QUADRATIC might give the better results. Ultimately you'll have to test them: set this option on newly created image resources as soon as possible, combine it with the high quality flag when saving jpegs, and you should be pretty free from artifacts when using GD.


try using imagecopyresampled instead.


I use timthumb for this. Just giving another option ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜