Most reliable source of image width

Started by ben80, February 13, 2022, 04:09:36 PM

Previous topic - Next topic

ben80

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

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/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

#3
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?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ben80

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?

StarGeek

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ben80

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

delerious

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, it says the ImageSize composite tag is derived from ImageWidth, ImageHeight, ExifImageWidth, ExifImageHeight, and RawImageCroppedSize.

Phil Harvey

What format of images are you asking about?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

delerious

#11
I deal mostly with JPG and MOV. But your question suggests there is a different answer depending on the format?

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

delerious

What about for CR2, DNG, and HEIC photos, and AVI and MP4 videos?

StarGeek

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/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype