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

Access image height/width beyond EXIF tags #149

Closed
PanierAvide opened this issue Oct 1, 2024 · 2 comments
Closed

Access image height/width beyond EXIF tags #149

PanierAvide opened this issue Oct 1, 2024 · 2 comments

Comments

@PanierAvide
Copy link

PanierAvide commented Oct 1, 2024

Hello,

First thanks for your work on this library, which is super useful and we use it extensively on Panoramax, especially on a little lib to read GPS and dates from JPEG images.

I'm wondering if there is a way to read image height/width from file itself when the dimensions are not available in EXIF tags (we used Exif.Photo.Pixel[X|Y]Dimension or Xmp.GPano.CroppedAreaImage[Height|Width]Pixels for now). In this image, not EXIF tags seem to contain this information : example.jpg.zip

Extracted EXIF & all tags:

{'Exif.Image.Make': 'GoPro',
'Exif.Image.Model': 'GoPro Max',
'Exif.Image.ExifTag': '78',
'Exif.Photo.DateTimeOriginal': '2024:09:29 17:10:00',
'Exif.Photo.OffsetTimeOriginal': '+00:00',
'Exif.Photo.SubSecTimeOriginal': '293000',
'Exif.Image.GPSTag': '150',
'Exif.GPSInfo.GPSLatitudeRef': 'N',
'Exif.GPSInfo.GPSLatitude': '49/1 11/1 548764799/10000000',
'Exif.GPSInfo.GPSLongitudeRef': 'W',
'Exif.GPSInfo.GPSLongitude': '0/1 21/1 325688400/10000000',
'Exif.GPSInfo.GPSAltitudeRef': '0',
'Exif.GPSInfo.GPSAltitude': '6330/100',
'Exif.GPSInfo.GPSTimeStamp': '17/1 10/1 293000/1000000',
'Exif.GPSInfo.GPSImgDirectionRef': 'T',
'Exif.GPSInfo.GPSImgDirection': '7766/100',
'Exif.GPSInfo.GPSDateStamp': '2024:09:29',
'Exif.Photo.UserComment': 'Lavc58.134.100'}

Exiftool manages to detect image size :

$ exiftool -G image.jpg
[ExifTool]      ExifTool Version Number         : 12.93
...
[File]          Image Width                     : 128
[File]          Image Height                    : 96
...
[Composite]     Image Size                      : 128x96
...

I have no idea if this is feasible with pyexiv2 😅 Thanks for your help 😀

Best regards

@LeoHsiao1
Copy link
Owner

Hi!
I just released v2.15.0, which adds img.get_pixel_width() and img.get_pixel_height().
It is not recommended to get the width and height from the image metadata, as the metadata may be falsified.

@PanierAvide
Copy link
Author

Works like a charm, thanks for your fast implementation 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants