0
\$\begingroup\$

Are there any exif tags to crop an image without modifying its underlying image data?

Say I have a JPEG where I want to crop out its top 5 rows, bottom 2 rows, and right 3 columns (leaving the left side uncropped).

I don't want to have to recompress it as a new JPEG with different image data, so I can avoid quality loss from the second lossy compression.

I don't want to have to save it as a lossless PNG because that will massively increase the file size.

I just want to embed some exif tags that instruct image libraries/programs to crop the image derived from the underlying image data (which remains unchanged) at the desired places.

Sort of like how the Orientation exif tag rotates an image without modifying the underlying image data.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You can check:

DefaultUserCrop

Specifies a default user crop rectangle in relative coordinates. The values must satisfy: 0.0 <= top < bottom <= 1.0, 0.0 <= left < right <= 1.0.The default values of (top = 0, left = 0, bottom = 1, right = 1) correspond exactly to the default crop rectangle (as specified by the DefaultCropOrigin and DefaultCropSize tags).

from here.

There are also metainfo tags you can check:

Crop Left Margin
Crop Right Margin
Crop Top Margin
Crop Bottom Margin

Be aware all these tags accept floating point values. And as you want to crop number of lines and columns you should recalculate the values for every image.

\$\endgroup\$
5
  • \$\begingroup\$ I believe that DefaultUserCrop is part of the DNG standard (page 64). It appears in the EXIF block, but is not part of the EXIF standard. I haven't heard of an image viewer that will respect a virtual crop such as this. \$\endgroup\$
    – StarGeek
    Commented Aug 2 at 16:33
  • \$\begingroup\$ @StarGeek, on the top of the page (see link) I read: "These are the Exif tags as defined in the Exif 2.3 standard." And under id 0xc7b5 I see this tag. \$\endgroup\$ Commented Aug 2 at 16:41
  • \$\begingroup\$ @RomeoNinov In my PDF of the standard (Exif 2.31 from 2016) I don't see these values. They appear to be used in RAW images to indicate extra pixels (used for instance for lens aberration correction). \$\endgroup\$
    – xenoid
    Commented Aug 2 at 22:07
  • \$\begingroup\$ The Exiv2 page is incorrect. Not all of those are part of the standard. If you follow the link they provide to the Exif Version 2.3 standard (which is a very old version), you will find it doesn't appear there. You can also check the Exif Version 3.0 spec (Download here or see copy on Archive.org). \$\endgroup\$
    – StarGeek
    Commented Aug 3 at 3:04
  • \$\begingroup\$ The Exiftool EXIF tags page is a better source, as the author of exiftool keeps things up to date. Any tag that is underlined on that page is part of the official EXIF spec. \$\endgroup\$
    – StarGeek
    Commented Aug 3 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.