raki
raki

Reputation: 2293

php image resize creating image with lower quality

I am using the simple image resize methode

list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;


$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);


imagejpeg($image_p, null, 100);

Eventhoug i had given the quality to maximum , when it comes to smaller image size , the generated image is of very poor quality (original 500px to new 100px ).

Is there any other way to increase the image quality ?

Upvotes: 0

Views: 1073

Answers (2)

cangak
cangak

Reputation: 132

try this

<?php

header('Content-type: image/jpeg');

$image = new Imagick('image.jpg');

// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);

echo $image;

?>

source http://php.net/manual/en/imagick.examples-1.php

Upvotes: 0

acme
acme

Reputation: 14866

Yes there is a way to increase the quality: use ImageMagick instead of the GD library, if possible. The quality of the GD library is pretty poor.

Upvotes: 3

Related Questions