Fix w/h after Exif rotation

old-stable24
Varun Patil 2022-10-15 22:23:07 -07:00
parent 3de3e2fd99
commit 37d9307bab
1 changed files with 7 additions and 0 deletions

View File

@ -321,6 +321,13 @@ class Exif {
public static function getDimensions(array &$exif) { public static function getDimensions(array &$exif) {
$width = $exif['ImageWidth'] ?? 0; $width = $exif['ImageWidth'] ?? 0;
$height = $exif['ImageHeight'] ?? 0; $height = $exif['ImageHeight'] ?? 0;
// Check if image is rotated and we need to swap width and height
$rotation = $exif['Rotation'] ?? 0;
if ($rotation == 90 || $rotation == 270) {
return [$height, $width];
}
return [$width, $height]; return [$width, $height];
} }