Manual image upload not working correctly for portrait images

I noticed a curious bug, I was uploading portrait images (.jpg files) through the panel, which worked perfectly.
But I got one image which was too big for php to handle (3032×4024)? So I uploaded that one manually.

Fun thing I noticed is that it automatically decided that the image should be a landscape image? So the image is displayed sideways in the panel, and also its dimensions are swapped eventhough it is displayed as portrait when openend in a native image-viewer.

I tried to look for some properties in the image-txt file and in the cache files, but nothing I can find points to why it swapped the dimensions.

On some further testing, it also swaps dimensions for images with smaller dimensions, as long as you add them manually.

So the question is, how to fix this (the manual way) / which files needs to be edited to correct this?

Probably related Exif orientation tag related issues and how to solve them · Issue #2695 · getkirby/kirby · GitHub

A long standing bug judging the creation date.

For if anyone has this problem, I could fix it by re-saving the image with a image-editor (Paint.net in my case).

  • create a new image/document (with the correct canvas-size)
  • copy-paste the image in the new image/document
  • save the image/document and you got a working image-file

The reason why this works is because the image I used had the EXIF meta-data set. These are properties added by camera’s, smartphones, scanners etc. so a system can determine image meta-data including its orientation. In my case the images were made with an iphone and for some reason those meta-data were misinterpreted by the image-engine Kirby uses (or wrongly set by the iphone, no clue which one it is).

By re-saving the image with an image-editor (using a new document, and copy-paste the image on the new document) you are able to create an image-file without these meta-data, which means the system falls back to the original (and usually the correct) image dimensions/orientation.