processwire-issues
processwire-issues copied to clipboard
Incorrect cropping of portrait-format images when focus zoom used
Short description of the issue
There seems to be a bug with $pageimage->size() when focus and zoom are used together on portrait-format images that have EXIF data.
I noticed this problem first with an image uploaded by a client and then confirmed with two of my own images.
In the examples below both images are focused on the lower right area with the zoom control dragged all the way to the right (maximum zoom in). The issue doesn't occur if zoom is not used.
Notice how the landscape-format image is cropped correctly but not the portrait-format image.
With GD image engine:
With ImageMagick image engine:
I'm guessing this might have something to with the width and height of the portrait-format image not being calculated correctly according to the orientation value in the EXIF data? Although $pageimage->width is showing the correct value for both images so not sure.
The issue doesn't occur with portrait-format images that don't contain EXIF data.
The images used: https://user-images.githubusercontent.com/1538852/192436441-48343c29-f17e-4206-8167-8ec3236b897d.jpg https://user-images.githubusercontent.com/1538852/192436443-2ae68d89-23bf-443d-bb64-2f72ab6328ed.jpg
Setup/Environment
- ProcessWire version: 3.0.205
I think this is probably similar to this resolved issue, where getimagesize()
doesn't correct the width and height according to the image orientation. Because when I add a similar correction to ImageInspector::inspect()
...
if($this->info['orientation'] > 4) {
// Image has portrait orientation so reverse width and height info
$this->info['width'] = $info[1];
$this->info['height'] = $info[0];
}
...it fixes the incorrect crop on the variation.
BUT, it then breaks the admin thumbnail (it seems like it doesn't ignore the focus when creating the admin thumb?) so there must be more that's needed to fix this properly.