image icon indicating copy to clipboard operation
image copied to clipboard

resize() throws away EXIF data

Open adamndev opened this issue 7 years ago • 4 comments

I'm getting on quite well with Image in general, but can't find anything in the docs or any open issues that mention this.

If you want a thumbnail for general purpose then throwing away exif data is probably a good move to reduce file size with unnecessary extra data, but with Imagick, using resize keeps exif data, while thumbnail removes it.

For this project I need the photo exactly as the original, just smaller. Have I missed something somewhere, or am I alone in needing this?

Here's what I'm using...

// Create new Image Instance and use Exif data to orientate $photo = Image::make ( $fullPath )->orientate();

    // Find orientation for resize and watermark image
    $photo->width() > $photo->height() ? $orientation = 'landscape' : $orientation = 'portrait';
    
    // Set Dynamic Vars
    if ( $orientation == 'landscape' ) {
        $width = null; $watermark = $watermarkLandscape;
    } else {
        $height = null; $watermark = $watermarkPortrait;
    }
    
    // Resize Image
    $photo->resize ( $width, $height, function ( $constraint ) {
        $constraint->aspectRatio(); // With Aspect Ratio
    });
    
    // Save LOCAL with medium quality
    $photo->save ( $lclThumb, 30 );

adamndev avatar Sep 01 '18 21:09 adamndev

The real problem is that in ten months nobody has commented on such serious issue. Is it possible ?

borgogelli avatar Jul 25 '19 14:07 borgogelli

I agree that it is very useful to keep EXIF data after resize. I want to use ImageDescription from each image for alt tag, but it is not possible, because thumbnails resized with empty EXIF data. Is there any way to keep it?

schel4ok avatar Mar 04 '21 19:03 schel4ok

+1

rus-ik avatar Jul 20 '21 07:07 rus-ik

+1

DaPoHou avatar Mar 29 '22 02:03 DaPoHou

+1

tmartty avatar Dec 06 '22 11:12 tmartty

+1

Vakil-Parth avatar Feb 02 '23 10:02 Vakil-Parth

I think you can change resize() to fit(). The fit() method resizes and crops the image to precisely match the specified dimensions. It takes two parameters: the width and height of the desired dimensions. The fit() method will resize the image to fit within the specified dimensions, maintaining its aspect ratio. If necessary, the image will be cropped to eliminate any excess parts and ensure the final image matches the specified dimensions exactly.

EXP: // Resize Image $photo->fit( $width, $height, function ( $constraint ) { $constraint->aspectRatio(); // With Aspect Ratio });

thucpd avatar Jul 12 '23 19:07 thucpd

A distinction must be made here. With Imagick, the metadata should be preserved, while the GD library cannot save EXIF data. To make things even more complicated, there was a bug in version 2 of Intervention Image where EXIF data was lost even with Imagick. This should be fixed in version 3.

olivervogel avatar Jan 08 '24 10:01 olivervogel