Kirby returns incorrect orientation for some images

Hi there,

I ran into a weird issue where file()->ratio() returns the reversed ratio for me. Upon closer inspection in the panel I realized that Kirby indeed thinks the image is a landscape one when it is displayed as a portrait and has the dimensions switched (see screenshot).

This only happens to a few images. As Kirby’s panel does the preview correctly and also calculates the thumbs correctly, I wonder why it thinks that the ratio is reversed? Is there any way to work around this? Thanks!

trych

I guess related with following issue:

Thanks @ahmetbora, this issue seems indeed related. While the proposed plugin in the Github issue resolves the orientation problem, the resulting image is compressed like crazy (1,5MB → 350KB).

Also, it seems each and every image gets compressed (even the non-problematic ones) which I would really like to avoid.

Since the images are also not distorted and I just need to get the correct orientation, I wonder if there is a less destructive way to get to the actual orientation? I mean if Kirby displays the image correctly and creates thumbs correctly, I feel it should somehow be able to correctly tell me the orientation as well.

Ok, I kind of managed to work around this problem, by basically doing

$img->resize(128)->ratio();

instead of

$img->ratio();

That’s all I need in this specific case, still, I feel that’s a very weird hack somehow. :see_no_evil:

The other option would probably be a custom file method that calculates the dimensions/ratio based on the exif data.

Wouldn’t that be what Kirby does behind the scenes anyway? I feel when the orientation is messed up in this image somehow I will not be able to out-smart the existing solution by writing my own file method. I think I’ll stay with the resize thing for now.