Laravel Image Intervention resize quality loss

- 1 answer


In my Laravel web-application I make use of the Intervention Image library. I'm saving three versions of the uploaded image: 'original', '500_auto' and a custom size image.

$image = Image::make(Input::file('file');

// Save the orignal image
$image->save($folder . 'original.' . $extension);

// Save 500_auto image
$image->resize(500, null, function($constraint) {
$image->save($folder . '500_auto.' . $extension, 100);

// Check if size is set
if (isset($config->images->width) && isset($config->images->height)) {
    // Assign values
    $width  = $config->images->width;
    $height = $config->images->height;
    // Create the custom thumb
    $image->resize($width, $height, function($constraint) {
    $image->save($folder . $width . '_' . $height . '.' . $extension, 100);

The driver of Intervention is set in the config as 'gd':

'driver' => 'gd'

This is the image I'm uploading: original.jpg

Original image

And this is the result from the custom thumb with the config settings set to exact the original sizes (1800 x 586): 1800_586.jpg

Resized image

As you can see the second image there is a lot of quality loss in the resized image. How can I fix this?




You're first resizing the image to a small format, then you take the small image and resize that to the original size again. If you reverse the order, you'll go from original size -> original size -> small size instead.

Personally, I usually prefer to redo the Image::make() call for every new image, just to make sure I don't screw something like this up along the way.