PixelXDimension & PixelYDimension tags

Started by VladoBENZ, May 21, 2018, 07:59:55 PM

Previous topic - Next topic

VladoBENZ

Hello, guys, I would like to ask you a question regarding these tags, sorry if this topic had been discussed, I could not find the right info for me. From what I have read here, it occurs to me that there are no such tag names in exiftool. these tags should be called exifimageheight and exifimagewidth. but apparently there is some difference between the two couples, because my situation shows it. So my case is this:
I have a photo, and the exif info on it is in big-endian....i want to change the byte order to little endian. i use this command:
exiftool -all= -tagsfromfile test.jpg -all:all -unsafe -exifbyteorder=little-endian test.jpg
So far, so good, when i type "exiftool test.jpg", everything looks the same as in the original, except the byte order.
But I use another app on windows, called Exif Pilot. and when I opened the original file and the edited file with Exif Pilot, I noticed a difference between the metadata of the two files. I attached screenshots. Basically in the original file PixelXDimension & PixelYDimension tags are present, but in the edited file they are missing. Do someone have an idea why this happens and how can I fix it......my goal is to change the byte order to little-endian, but in the same time to preserve those two tags, so Exif Pilot shows them.

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 ($).

VladoBENZ

Yes, I've seen it, but it doesnt explain anything, the only thing in the documentation is this:

0xa002    ExifImageWidth    int16u:    ExifIFD    (called PixelXDimension by the EXIF spec.)
0xa003    ExifImageHeight    int16u:    ExifIFD    (called PixelYDimension by the EXIF spec.)

which doesnt explain the behavior in my case. if exifimagewidth and pixelxdimension are exactly the same tag, then why in the edited file i have the exifimagewidth tag, but exif pilot suddenly stops reading the pixelxdimension tag....doesnt make any sence to me.

Phil Harvey

Sorry, I didn't have much time and didn't read your entire post.

Could you send me the two pictures so I can take a look at the differences?  (philharvey66 at gmail.com)

- 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 ($).

Phil Harvey

Wow.  These files are basically identical except for the change in EXIF byte order.

I can't see why Exif Pilot is having a problem reading one of them.

I think you should ask the Exif Pilot people why their software isn't reading this.

- 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 ($).

VladoBENZ

Yes, I will. It is very strange...today I tried to edit the PixelXDimension tag from Exif Pilot...I put a value of 0 of the tag....and something even stranger happened.....basically Exif Pilot stopped reading the tag (although it was edited in the app itself), and when I tried to view the image in exiftool, the ExifImageWidth tag had a value of "3860 0". Very strange value. 3860 was the old value, space, and 0 at the end.

Phil Harvey

Odd.  It sounds like it was storing 2 integers.  Try running this on the file to see what warnings ExifTool gives:

exiftool -validate -warning -a 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 ($).

VladoBENZ

It shows OK, but obviously that is a problem with Exif Pilot. When Exif Pilot changes the value of the tag, it disappears, shows that it is a problem with their program...at least I think this way.

Phil Harvey

Yes.  That definitely shows an Exif Pilot problem.

- 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 ($).

VladoBENZ

Hi, Phil, sorry to bother you, but I just found out something interesting...I took a brand new image file, and edited the exifimagewidth tag, using exiftool, to the same it was before......for example the image had a value of 3840, and i used the command "exiftool -exifimagewidth=3840 file". So basically the two images should be absolutely identical, shouldnt they? So i decided to open both files with hex editor and compare them...and guess lol, they had a single difference...just a single byte, the original was 03, on the edited was 04...but obviously this difference should not be there....and when i manually edited this difference in a hex editor, voala, exif pilot read the pixelxdimension tag again. so obviously there is a reason to believe that exiftool is editing a byte, that should not be edited...because if i overwrite a value with the same value, there should not be a difference at all.

Phil Harvey

Good sleuthing.

This will be the TIFF format for the tag (3=SHORT, 4=LONG).  According to the EXIF spec, the pixel dimension tags may be either SHORT (int16u) or LONG (int32u).  ExifTool writes them as int16u by default.

Changing this single byte will only give a valid result if the file is little-endian (and the dimension is < 65536).

- 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 ($).

VladoBENZ

Ahaaaaaaaaa, great, probably thats the reason. so is there any way I write them in LONG, using exiftool?

Phil Harvey

You can override the built-in definition with a user-defined tag.  Here is a config file that will do this:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Exif::Main' => {
        0xa002 => {
            Name => 'ExifImageWidth',
            Writable => 'int32u',
            Mandatory => 1,
        },
        0xa003 => {
            Name => 'ExifImageHeight',
            Writable => 'int32u',
            Mandatory => 1,
        },
    },
);
1; # end


- 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 ($).

VladoBENZ

I did make a config file with the code you gave me, but now, when i use the command exiftool -exifimagewidth=...and so on, it gives me this warning:
can't modify constant item in scalar assignment at C:\.ExifTool_config line 4, near "'ExifImageWidth',"
i dont have an idea what that means.

Phil Harvey

It seems that you have "=" instead of "=>" in line 4 of the config file.
...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 ($).

VladoBENZ

You are a Genius! Now it works like a charm, Exiftool overwrites the tag, and Exif Pilot reads it without disappearing! Thank you, Phil!!!!

Phil Harvey

Great!  You should still report this bug to Exif Pilot though.
...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 ($).

VladoBENZ

Yes, I reported it already...thank you, Phil. Oh, and last question, if you can tell me, i have 200 photos that i want to convert from big endian to little endian, i use this command:
exiftool -all= -tagsfromfile test.jpg -all:all -unsafe -exifbyteorder=little-endian test.jpg
but this is for every single file, a sepperate one....is there any way to convert all of them with one command...and is there a point to add -u (for unknown tags) in this command or it is going to copy them by default... (Sony specific tags)

Phil Harvey

The batch version of this command would be:

exiftool -all= -tagsfromfile @ -all:all -unsafe -exifbyteorder=little-endian -ext jpg DIR

-u doesn't have an effect when writing.  The unknown makernote tags will be copied because the makernotes are copied as a block.  Other unknown/unwritable tags will be dropped.

- 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 ($).

VladoBENZ

mmm I tried that command, but it is not working, I mean the exiftool is doing something, but at the end every file kept its byteorder the way it was original. just to clarify, after -tagsfromfile is @ sign, right? i copied the command exactly i think, but not working...if i make it file by file, it is working though.

Phil Harvey

Add -v3 to see lots of detail about what ExifTool is doing.

- 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 ($).