ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: ben80 on February 13, 2022, 04:09:36 PM

Title: Most reliable source of image width
Post by: ben80 on February 13, 2022, 04:09:36 PM
Good evening everyone,

What is the most reliable tag to get the width of a jpg image?

I found out that some of my jpgs return a width using "EXIF:ExifImageWidth" and some using "EXIF:ImageWidth".
If i use the composite tag "ImageWidth" do i get independent of this?

When i use the tag "ImageWidth" (running from python), then exiftool returns the value using the key "File:ImageWidth".
Is this always the case?

Thanks a lot for your help.
Title: Re: Most reliable source of image width
Post by: Phil Harvey on February 14, 2022, 09:46:59 AM
This is a good point.  PDF Keywords aren't currently handled properly when adding to an existing list.  Your 2-step method is the work-around, but I will look into this and see how difficult it would be to improve the situation in a future release.

- Phil
Title: Re: Most reliable source of image width
Post by: StarGeek on February 14, 2022, 09:53:24 AM
For a jpeg, you would use ImageWidth and ImageHeight.  The EXIF image tags are filled out whatever program is writing the file and can be inaccurate if a program edits the file without editing those tags.

Personally, for this reason, I find them absolutely useless as very few programs will actually write the tags, even though EXIF:ExifImageWidth and EXIF:ExifImageHeight are considered mandatory according to the spec.  They are among the list of tags that I automatically remove in my workflow, though if you want to keep them and make sure they're accurate, you could run this command
exiftool "-EXIF:ExifImageWidth<ImageWidth" "-EXIF:ImageWidth<ImageWidth" "-EXIF:ExifImageHeight<ImageHeight" "-EXIF:ImageHeight<ImageHeight" /path/to/files/
Title: Re: Most reliable source of image width
Post by: StarGeek on February 14, 2022, 09:54:01 AM
Quote from: Phil Harvey on February 14, 2022, 09:46:59 AM
This is a good point.  PDF Keywords aren't currently handled properly when adding to an existing list.  Your 2-step method is the work-around, but I will look into this and see how difficult it would be to improve the situation in a future release.

- Phil

Responding to the wrong post?  Maybe this one (https://exiftool.org/forum/index.php?topic=13305.0)?
Title: Re: Most reliable source of image width
Post by: ben80 on February 14, 2022, 10:09:33 AM
Quote from: StarGeek on February 14, 2022, 09:53:24 AM
For a jpeg, you would use ImageWidth and ImageHeight.  The EXIF image tags are filled out whatever program is writing the file and can be inaccurate if a program edits the file without editing those tags.

I am happy with using only ImageWidth and ImageHeight (abandoning EXIF:ExifImageWidth and EXIF:ImageWidth).

Then my question is:
If i use ImageWidth and ImageHeight does exiftool return as File:ImageWidth and File.ImageHeight?
Title: Re: Most reliable source of image width
Post by: StarGeek on February 14, 2022, 10:42:47 AM
For a jpeg/tiff/png, I believe so, though you could always specify File:ImageWidth/Height to be sure.

For a RAW file type such as NEF/CR2, I'm not sure.  I could have sworn that for RAW files it would return the File group dimensions because I was having some problems with CR2 dimensions some time ago, but my quick test doesn't give File results on those file types.
Title: Re: Most reliable source of image width
Post by: Phil Harvey on February 14, 2022, 03:12:04 PM
Quote from: StarGeek on February 14, 2022, 09:54:01 AM
Responding to the wrong post?  Maybe this one (https://exiftool.org/forum/index.php?topic=13305.0)?

Ooops.  Thanks.

- Phil
Title: Re: Most reliable source of image width
Post by: ben80 on February 15, 2022, 05:07:43 PM
QuoteFor a jpeg/tiff/png, I believe so, though you could always specify File:ImageWidth/Height to be sure.
Thanks for your help, this works for me.
Title: Re: Most reliable source of image width
Post by: Phil Harvey on February 15, 2022, 05:34:05 PM
The group for the best ImageWidth/Height may change, but it should (hopefully) always be the priority tag, so you shouldn't have to worry about the group.  It will be the one you get if you don't specify a group.  The only exception I know is for HEIC files -- I need to fix things to properly prioritize the size tags for this type of file.

- Phil
Title: Re: Most reliable source of image width
Post by: delerious on January 03, 2024, 04:24:48 AM
Quote from: StarGeek on February 14, 2022, 09:53:24 AMFor a jpeg, you would use ImageWidth and ImageHeight.  The EXIF image tags are filled out whatever program is writing the file and can be inaccurate if a program edits the file without editing those tags.
I have noticed this too.

Is the Composite:ImageSize tag accurate? I noticed on this page (https://exiftool.org/TagNames/Composite.html), it says the ImageSize composite tag is derived from ImageWidth, ImageHeight, ExifImageWidth, ExifImageHeight, and RawImageCroppedSize.
Title: Re: Most reliable source of image width
Post by: Phil Harvey on January 03, 2024, 07:18:15 AM
What format of images are you asking about?

- Phil
Title: Re: Most reliable source of image width
Post by: delerious on January 04, 2024, 12:50:33 AM
I deal mostly with JPG and MOV. But your question suggests there is a different answer depending on the format?
Title: Re: Most reliable source of image width
Post by: Phil Harvey on January 04, 2024, 08:03:01 AM
For JPG images and MOV videos, Composite:ImageSize should be accurate.

For some RAW formats the ImageSize may not be what you expect.

Other formats I would have to answer on a case-by-case basis.

- Phil
Title: Re: Most reliable source of image width
Post by: delerious on January 05, 2024, 03:35:59 AM
What about for CR2, DNG, and HEIC photos, and AVI and MP4 videos?
Title: Re: Most reliable source of image width
Post by: StarGeek on January 05, 2024, 12:30:03 PM
You'll have to check the files.  Use this command to see all the width/height/size type tags in the file.  If you're on Mac/Linux, put quotes around the parts with the asterisk
exiftool -G -a -s -*size* -*width* -*height* /path/to/files/