exif tags to crop image without modifying its underlying image data

Started by xtu6, August 01, 2024, 08:17:45 PM

Previous topic - Next topic

xtu6

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.

Phil Harvey

Unfortunately there aren't any tags that will do this for you.  Basically, the only EXIF tags that are honoured universally for image rendering are the colorspace and orientation tags.

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

xtu6

Quote from: Phil Harvey on August 01, 2024, 09:26:28 PMthe only EXIF tags that are honoured universally
Are any proprietary crop tags honored by Apple software (like the Music app, and/or macOS Finder), but are not universally honored? I assume not, but I figured I'd ask just in case...

Thanks for the info.

wywh

I have used GraphicConverter (Mac) to losslessly crop .jpg images. The crop must be done in 8 or sometimes 16 pixel increments.

- Matti

StarGeek

Quote from: xtu6 on August 01, 2024, 09:49:29 PMAre any proprietary crop tags honored by Apple software (like the Music app, and/or macOS Finder), but are not universally honored? I assume not, but I figured I'd ask just in case...

I can't speak specifically for the Mac, but I have never seen any image viewer that will display a virtual crop, including several cross-platform programs.

There are some crop type tags in XMP, specifically in Adobe Camera Raw Defaults and Adobe Photoshop Camera Raw tags, but I believe these are mostly used in the editing history. They're not something I've ever seen any image viewer take into account.

To expand on @wywh's post, you can losslessly crop JPEGs on 8 pixel (sometimes 16 pixel) blocks on the left and top sides.  Crops on the right and bottom can be partial crops. There aren't very many programs that will do this for you, though.

I show an example in this post where I combine the command line program jpegtran and ImageMagick to figure out the dimensions an image needs to be cropped to remove the border and then pass those dimensions to jpegtran.  The after image shows that there is still a bit of a border on the left and top, as the border edge did not fall upon an 8 pixel block size, but the bottom and right sides have been completely trimmed. This is a lossless operation.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

xtu6

Thanks all for the info. I'll look into the `jpegtran` cropping hack.