Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata: Default to landscape orientation if data is invalid #1052

Closed
JamesSwift opened this issue Feb 16, 2021 · 19 comments
Closed

Metadata: Default to landscape orientation if data is invalid #1052

JamesSwift opened this issue Feb 16, 2021 · 19 comments
Assignees
Labels
enhancement Refactoring, improvement or maintenance task released Available in the stable release

Comments

@JamesSwift
Copy link

Hi. Once again, thanks for your hard work on this project, I really do appreciate it.

I spotted a small bug. Photos form a certain old camera phone (HTC HD2 if memory serves) sometimes display extremely distorted when in the viewer, but the thumbnails render fine. I believe that the photo viewer is passing the aspect ratio in reverse in these cases. For instance instead of 1 16:9 image being displayed as 16:9, it is displayed as 9:16. I've attached a screenshot and the original file in case it's meta data help track down the bug.

Thanks for your time.

Thumbnail from gallery:
gallery

Photo Viewer:
screenshot

Original file:
20100414_142454_ADE31F95

@alexislefebvre
Copy link
Contributor

Do the exif metadata contain wrong values?

@lastzero
Copy link
Member

You can use the reader tool of go-exif to find all rotation tags. Old files sometimes contain conflicting duplicates.

@JamesSwift
Copy link
Author

I'm unsure. All the image viewers I have tried it on open the files just fine, even photoprism's thumbnail generator gets it right. Just the image viewer gets it wonky. Wondered if that would be a clue to the solution.

@JamesSwift
Copy link
Author

That's interesting, photoprism's files viewer reports it as portrait, but it's definitely landscape.

UID | FQOMTQF3T3VEUIA0
Hash | 486f1fdb34d68e0087dc620118cbd97a9c488003
Name | 2010/04/20100414_142454_ADE31F95.jpg
Original Name | Takeout/Google Photos/Brighton, London April 2010/IMAG0477.jpg
Size | 1216 × 2048, 0.5 MB
Type | JPG
Codec | JPEG
Primary | Yes
Portrait | Yes
Aspect Ratio | 0.59
Main Color | Green
Chroma | 12 / 100
Added | Feb 16, 2021, 5:25 PM in 1,685 ms

@lastzero
Copy link
Member

We use different libraries for this, that's why I said conflicting duplicates :)

@JamesSwift
Copy link
Author

So, is there anything more I can do to help with this?

@alexislefebvre
Copy link
Contributor

What is the orientation of this image?

@lastzero lastzero added the technical-support Support request label Feb 17, 2021
@lastzero lastzero changed the title Bug: Aspect ratio is flipped on some images Metadata: Aspect ratio is flipped on some images Feb 17, 2021
@JamesSwift
Copy link
Author

What is the orientation of this image?

So that info is for the image I embedded in the original post. It's landscape, but PP thinks it is portrait, hence the distortion as it forces it into that shape.

@JamesSwift
Copy link
Author

I'll try to get the data you want to too you soon, my toddler just threw my laptop on the ground 🤦‍♀️ Think I'd better give him some attention.

@graciousgrey
Copy link
Member

Exiftool and exif-read-tool show that the files metadata contains an invalid value for orientation. So PhotoPrism can't know its real orientation and uses portrait as fallback

@JamesSwift
Copy link
Author

Exiftool and exif-read-tool show that the files metadata contains an invalid value for orientation. So PhotoPrism can't know its real orientation and uses portrait as fallback

Thanks, you just beat me to posting the same thing ha ha. However, I notice that it reports width and height correctly, perhaps instead of having a default of profile, the default could be based on the reported width/height ratio?

@JamesSwift
Copy link
Author

So, I'm not used to go (mostly php and js for me), but it looks like you check case of orientation first, then if that is 0, check for rotation. Perhaps you could add a check that if it is still 0 then calculate from width & height?

if data.Orientation == 0 {

@lastzero
Copy link
Member

We extract width and height directly from the image but there is another exif reader for thumb generation that may be confused by the header... orientation is something like 834534... values between 1 to 8 are valid. You see the issue?

@JamesSwift
Copy link
Author

We extract width and height directly from the image but there is another exif reader for thumb generation that may be confused by the header... orientation is something like 834534... values between 1 to 8 are valid. You see the issue?

Indeed. Stupid microsoft camera app on the HD2. But given it's popularity back in the day, there will be lots of photos out there with invalid orientation data, would it be worth adding a check for this case as mentioned above?

@graciousgrey
Copy link
Member

$ exiftool -j metaOrientation.jpg

  "SourceFile": "metaOrientation.jpg",
  "FileName": "metaOrientation.jpg",
  "ExifByteOrder": "Big-endian (Motorola, MM)",
  "Orientation": "Unknown (56628)",
  "DateTimeOriginal": "2010:04:14 14:24:54",

$ exif-read-tool -f metaOrientation.jpg

IFD-PATH=[IFD] ID=(0x0112) NAME=[Orientation] COUNT=(1) TYPE=[SHORT] VALUE=[[56628]]
IFD-PATH=[IFD/Exif] ID=(0x9003) NAME=[DateTimeOriginal] COUNT=(20) TYPE=[ASCII] VALUE=[2010:04:14 14:24:54]

@lastzero
Copy link
Member

We should default to landscape if possible.

@lastzero lastzero changed the title Metadata: Aspect ratio is flipped on some images Metadata: Default to landscape orientation if data is invalid Feb 17, 2021
@lastzero lastzero added enhancement Refactoring, improvement or maintenance task and removed technical-support Support request labels Feb 17, 2021
@lastzero lastzero added the please-test Ready for acceptance test label Feb 17, 2021
@lastzero lastzero self-assigned this Feb 17, 2021
@lastzero
Copy link
Member

lastzero commented Feb 17, 2021

@JamesSwift
Copy link
Author

I can confirm this has fixed my issue. Thank you very very much ✔😊

I was about to say it hadn't, then I realized I needed to reindex. I started it and thought "this is going to take forever! I wish there was a way to only reindex one folder..." Then remembered there was 🤦‍♀️, so I did that. I love PP, you've designed the backend so well!

@lastzero lastzero added released Available in the stable release and removed please-test Ready for acceptance test labels Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Refactoring, improvement or maintenance task released Available in the stable release
Projects
Status: Release 🌈
Development

No branches or pull requests

4 participants