tags:

views:

56

answers:

2

Hi,

i have a this function which resizes images but the final quality looks blurred too much and not clear:

Any other class or a solution to improve the quality of thumbnails ?

Thanks

Other Note - i already changed the quality to 100 but nothing happened!

+2  A: 

First of all, welcome to StackOverflow.

Unless you provide some tests / screenshots we can't do much to help you, you seem to be using the right combination of functions (imagecreatetruecolor / imagecopyresampled) so my first guess would go to the $quality argument in imagejpeg and imagepng functions.

For imagejpeg I suggest you use $quality = 90. For imagepng should be $quality = 9.

You can also try sharpening the image by using a convulsion like this one right before saving the image:

ImageConvolution($dst_image, array(array(-1, -1, -1), array(-1, 16, -1), array(-1, -1, -1)), 8, 0);

For 3rdparty libraries I hear WideImage and Asido are quite good.

Alix Axel
hi, thanks for your nice answer, i looked at WideImage, looks pretty useful, but does it resizes and crops same time if the image is too long or wide ? i want the final size to be 40x40 so wide images wil be croped a bit from sides to fit thanks so much
Marlene Brant
@Marlene Brant: Yeah, you won't get the exact same functionality - I suggest you post some example images and respective output so that we can further help you.
Alix Axel
+1  A: 

If you have access to imagemagick, which is usually pretty prevalent on web-servers, you can save yourself a lot of headaches by using the buit-in convert command:

$cmd = escapeshellcmd("env convert -thumbnail $format " . 
    $_FILES['field_name']['tmp_name']; . " -interlace Line -enhance ".   $tmp_name);
loginx
Thanks for answer, unfortunately i don't have access to imageMagick.
Marlene Brant
imageMagick aka imagick is a superior choice, although if you can't update the PHP.INI then you can't access it.
TravisO