Gallery Problem - Incorrect Width and Height in EXIF Data Affecting PhotoSwipe Display #1694
-
Operating systemWin 7 Publii version0.46.1 Issue typeApplication Bug descriptionI have a problem with portrait and lengthwise pictures in the gallery. The portrait images are always shown stretched across the entire width. What is the problem and how can you solve the problem if you want to use different portrait and landscape photos in the gallery and then display them enlarged. Sample side: http://m-learning.info/2.html Steps to reproduceNo response Relevant log outputNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
What theme are you using? |
Beta Was this translation helpful? Give feedback.
-
Simple... i tried all versions |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Can you double check this? I downloaded the problematic image (http://m-learning.info/media/posts/2/gallery/20240905_115629.jpg) and ran
The image data has a width of 1365 pixels and height of 768 pixels, and pixel (0,0) is the top-right corner, i.e. it needs to be rotated 90 degrees counter-clockwise for display, and the displayed image will have width=768 height=1365. This is the same as what I'm seeing for portrait-type images exported as JPEG from Apple Photos, so photos with metadata like this are probably pretty common. Simon Willison has a good explanation of what's going on here, and his own experiences with Photoswipe requiring orientation-aware width and height to display images correctly: https://til.simonwillison.net/exif/orientation-and-location I've opened a pull request (#2039) to wrap the sizeofOf() function from the image-size module and swap width/height as necessary. |
Beta Was this translation helpful? Give feedback.
It's not a theme issue or, to be more specific, the PhotoSwipe script. The problem is with the image's EXIF data, precisely the width and height recorded in the EXIF info.
For example, look at this:
The EXIF data of your original image shows the wrong width and height, it should be the other way around.
Now, this is how it should look:
Below, download the image with the corrected width/height EXIF data and see that it will now render well in the gallery.