I wrote a script, which resizes my uploaded images in a batch locally and creates also thumbnails. The problem is, if some images are vertically oriented, but after resizing they are rotated horizontally.
This is due to exif orientation of the image. Is there a simple way to remove the orientation exif from image via PHP? I know it can be done by Imagick, but I can't/don't want to install it.
So any solution without it?
For now I am solving it by opening such an image in image editor and re-saving it without keeping exif info. After that when I resize such image in my script, the result is correct.
So I just want to remove exif from the image in my PHP script before resizing it.
I tried a function for checking the orientation exif:
function removeExif($filename) {
if (function_exists('exif_read_data')) {
$exif = exif_read_data($filename);
if($exif && isset($exif['Orientation'])) {
$orientation = $exif['Orientation'];
if($orientation != 1){
// $img = new Imagick($filename);
// $img->stripImage();
// $img->writeImage($filename);
}
}
}
}
So I just need to replace that Imagick part with something else, without installing any additional library, maybe using the already included GD or something.