resize() throws away EXIF data
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 );
The real problem is that in ten months nobody has commented on such serious issue. Is it possible ?
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?
+1
+1
+1
+1
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 });
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.