zola icon indicating copy to clipboard operation
zola copied to clipboard

The image resulting from image_resize() has width and height inverted (EXIF orientation problem)

Open gfauredev opened this issue 5 months ago • 2 comments

Bug Report

Environment

Zola version: 0.18.0

Expected Behavior

The dimensions in image_resize() function call should always be the dimensions of the resulting image.

If this is not possible, the function should prevent confusion, for example by warning the user, and provide a way to deal with that in templates, for example by providing an orientation field in get_image_metadata() output.

Current Behavior

The current function seem to apply before EXIF reorientation. For example here's my image not processed by Zola

❯ identify static/photos/testExif.jpeg
static/photos/testExif.jpeg JPEG 4032x3024 4032x3024+0+0 8-bit sRGB 2.4495MiB 0.000u 0:00.000

❯ identify -format '%[orientation]' static/photos/testExif.jpeg
RightTop%

and after zola build with resize_image(src=/photos/testExif.jpeg, width=2000, height=1000)

❯ identify static/processed_images/testExif.jpg
static/processed_images/testExif.357e1078f1bc4b6c.jpg JPEG 1000x2000 1000x2000+0+0 8-bit sRGB 259274B 0.000u 0:00.000

❯ identify -format '%[orientation]' static/processed_images/testExif.357e1078f1bc4b6c.jpg
Undefined% 

Which is very confusing because the resulting image doesn’t have the width and height I set in the resize function.

Step to reproduce

Try to resize_image() an image with EXIF orientation not null, the resize don’t apply where you expect.

gfauredev avatar Feb 29 '24 13:02 gfauredev

Raised a fix: https://github.com/getzola/zola/pull/2468

Let me know if you have any remarks

amtanq avatar Mar 31 '24 20:03 amtanq

Just tested it and it looks good, thanks for your fix :+1:

gfauredev avatar Apr 02 '24 19:04 gfauredev