Unable to Write Crop Data

Started by andrewj, November 15, 2024, 04:29:26 AM

Previous topic - Next topic

andrewj

Hi. I'm trying to write data about how the original was cropped to a processed JPG. I'm using the following command:

exiftool -DefaultUserCrop="500 500 1000 2000" "<file.jpg>"

This fails without any explanation, it just returns:
  0 image files updated
  1 image files unchanged

If I do a query for XMP:all it returns useful data, so I know the XMP section is initialised.

What am I doing wrong, please?

greybeard

Does the jpg have the DefaultUserCrop tag? This seems to be a DNG tag.

And if its the DNG tag then the values are defined as

Top, Left, Bottom, Right

and the allowed values are:

0 ≤ Top < Bottom ≤ 1.0
0 ≤ Left < Right ≤ 1.0

There does seem to be something strange in the way exiftool displays the tag - it displays integer values whereas they should be rationals.

Phil Harvey

#2
> exiftool -DefaultUserCrop="500 500 1000 2000" a.jpg -v2
Writing SubIFD:DefaultUserCrop
...

JPEG doesn't have a SubIFD, so there is no place to put this.  If you really want to be non-standard, you could do this:

exiftool -IFD0:DefaultUserCrop="500 500 1000 2000" FILE

These are rational, and ExifTool will show them as reals if they have fractional values.

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

greybeard

Quote from: Phil Harvey on November 15, 2024, 07:01:23 AMThese are rational, and ExifTool will show them as reals if they have fractional values.

Apologies - what confused me was that I was testing with an M11 DNG which had the following:

Running the command:

exiftool -G1 -DefaultUserCrop l1.dng
[IFD0]          Default User Crop              : 0 0 1 1
If I then run this command:

exiftool  -DefaultUserCrop="0.6 0.6 1 1"  l1.dng
and then running the same display command:

exiftool -G1 -DefaultUserCrop l1.dng
gives me:

[IFD0]          Default User Crop              : 0 0 1 1
but running:

exiftool -a -G1 -DefaultUserCrop l1.dng
shows:

[SubIFD]        Default User Crop              : 0.6 0.6 1 1
[IFD0]          Default User Crop              : 0 0 1 1

exiftool defaults to showing the value in the IFD0 group when duplicates are not requested, but updates without specifying a group write to SubIFD.

the moral is to always use -a when displaying and always specify the group when writing

StarGeek

Quote from: andrewj on November 15, 2024, 04:29:26 AMIf I do a query for XMP:all it returns useful data, so I know the XMP section is initialised.

To clarify a bit, DefaultUserCrop is not an XMP tag, so it won't show up there.

As greybeard says, it's a DNG tag. It appears in the EXIF group but is not part of the EXIF standard.

Do you want to write this so you can keep track of it or do you expect programs other than exiftool to display this data? Because the latter is unlikely.
"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

andrewj

Thanks for the explanations. I'm not expecting other tools than the one I'm developing to show the data, but I'd ideally like to find a "standard" home for it if possible, rather than a user-defined one. Is there any standard JPG field which could be used to park crop data in the form of four numbers?

Phil Harvey

There are various XMP crop-related tags, but none of them are a great fit for what you are 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 ($).

andrewj

Thanks. Can I also ask a slightly wider question? I'm developing a utility to display the focus points used for an image, similar to including them in the review on the camera screen. It already works fine for RAW files and JPGs which are "central" views of the image (even if scaled or evenly cropped in camera), but to work for processed JPGs I have to know how the image rectangle relates to the RAW image rectangle, i.e. the crop data.

If the image has been processed using some applications the crop data may be in an XMP file. If it's been processed by CaptureOne I can look for the C1 settings file. However there doesn't seem to be any standard home for crop data in the processed files themselves.

Am I missing a common way to get crop info for a JPG, or am I restricted to when I have a companion XMP or settings file available?

Thanks

greybeard

Quote from: andrewj on November 15, 2024, 10:59:52 AMThanks. Can I also ask a slightly wider question? I'm developing a utility to display the focus points used for an image, similar to including them in the review on the camera screen. It already works fine for RAW files and JPGs which are "central" views of the image (even if scaled or evenly cropped in camera), but to work for processed JPGs I have to know how the image rectangle relates to the RAW image rectangle, i.e. the crop data.

If the image has been processed using some applications the crop data may be in an XMP file. If it's been processed by CaptureOne I can look for the C1 settings file. However there doesn't seem to be any standard home for crop data in the processed files themselves.

Am I missing a common way to get crop info for a JPG, or am I restricted to when I have a companion XMP or settings file available?

Thanks

I'd be interested if you figure this out - I do a similar thing for FujiFilm images (focus points, faces and subject detection areas) but don't even try if the image has been cropped by a third party tool - only raws or jpegs straight out of the camera - not only do you need the crop area but also most image editors (like Lightroom) strip out the focus information.