rbreu / beeref

BeeRef Reference Image Viewer
GNU General Public License v3.0
501 stars 37 forks source link

screenshot dragged into BeeRef is reflected horizontally #20

Closed troy-lamerton closed 3 years ago

troy-lamerton commented 3 years ago

Describe the bug

Drag screenshot into BeeRef and it is reflected horizontally.

To Reproduce Steps to reproduce the behavior:

MacOS

  1. On MacOS, press Cmd+Shift+4 to take a screenshot of your screen
  2. Click [done] button

Then open BeeRef

  1. Drag Screenshot_x.png onto BeeRef
  2. https://i.imgur.com/XYuo35u.png

Expected behavior

Png files added to BeeRef should render similarly to other image viewer apps.

Screenshots

https://i.imgur.com/XYuo35u.png

Was reproduced with this screenshot: Screen Shot 2021-08-11 at 09 44 04

Debug log:

Not sure if needed or how to get this on MacOS. There is no Help menu on MacOS BeeRef.

rbreu commented 3 years ago

Could you upload the screenshot that caused the issue as a zipped file? The problem is if you upload it as an image, most sites do some image conversion stuff with it that might remove the metadata that caused the issue. Maybe I can reproduce the issue on my machine if I got the screenshot exactly as it is on your machine.

troy-lamerton commented 3 years ago

Screen Shot 2021-08-11 at 09.44.04.png.zip

andrsd commented 3 years ago

I ran into this as well. Basically any image I dropped into the main window is flipped (images saved from web or my own photos).

I tracked it down and attached patch fixes the issue:

--- a/beeref/fileio/image.py
+++ b/beeref/fileio/image.py
@@ -51,6 +51,8 @@ def exif_rotated_image(path=None):

     transform = QtGui.QTransform()

+    if orientation == exif.Orientation.TOP_LEFT:
+        return img.mirrored(horizontal=True, vertical=False)
     if orientation == exif.Orientation.TOP_RIGHT:
         return img.mirrored(horizontal=True, vertical=False)
     if orientation == exif.Orientation.BOTTOM_RIGHT:

However this would suggest that the orientation of the horizontal axis in Exif does not match what Qt thinks. So, definitely not the final fix to apply. Just an insight on what I found out...

IDK if this is MacOS X specific. I can try on Windows. I don't have a linux machine around.

EDIT: I was missing not in "definitely not the final fix to apply." 🤦

rbreu commented 3 years ago

Orientation.TOP_LEFT means that the image is already in the correct orientation and shouldn't be transformed further. I can reproduce this problem on Linux and with images that don't have exif information in the first place, so that part of the code isn't even reached — the QtGui.QImage(path) at the beginning of the function returns the images flipped for some reason.

I'll investigate this further.

rbreu commented 3 years ago

To clarify, you are both using the dev/master version from github, right? Because I found a bug that I introduced when I added text items. I'm going to close this bug with the fix; if you have issues with the released 0.1.1 version, please reopen this bug.

andrsd commented 3 years ago

Yes, I am using main since it has the Mac OS X tweaks. I can test with 0.1.1.

andrsd commented 3 years ago

Just tested with 0.1.1 and this is not happening there.