Recommended way to remove thumbails

Started by aperturemode, August 21, 2023, 05:47:58 PM

Previous topic - Next topic

aperturemode

Based on some other posts in this forum, it seems this is the typical way to remove thumbnails from jpegs:

exiftool -exif:ifd1:all= *.JPG

If I look at the ifd1 group on one of my images, it looks something like this:
[EXIF:IFD1]    Compression                    : JPEG (old-style)
[EXIF:IFD1]    XResolution                    : 96
[EXIF:IFD1]    YResolution                    : 96
[EXIF:IFD1]    ResolutionUnit                 : inches
[EXIF:IFD1]    ThumbnailOffset                : 2560
[EXIF:IFD1]    ThumbnailLength                : 11776
[EXIF:IFD1]    ThumbnailImage                 : (Binary data 11776 bytes, use -b option to extract)

My first question, is it safe to delete the EXIF:IFD1Compression tag? In other words, this tag refers to compression on the thumbnail and has nothing to do with the main image compression, correct?

As an alternative, I noticed when recreating tags with the command below, the thumbnail is not copied over (as the filesize noticeably decreases), however all the EXIF:IFD1 tags were copied over,

exiftool -r -overwrite_original -all= -tagsfromfile @ -all:all FILEorDIR

Second question, is this -tagsfromfile approach preferred over the first as it keeps all the tags?

Third question, can either approach be used to remove thumbnails from tifs, or is it safer to leave the tif thumbnail intact, as is recommended for dng and raw?

StarGeek

Quote from: aperturemode on August 21, 2023, 05:47:58 PMMy first question, is it safe to delete the EXIF:IFD1Compression tag? In other words, this tag refers to compression on the thumbnail and has nothing to do with the main image compression, correct?

For a jpeg, most likely. But some camera manufacturers write data into IFD1 that should be in IFD0.  The ModifyDate is the most common but I faintly recall seeing it happen with some other tags.

For a Tiff or any RAW file type (NEF, CR2, etc), then absolutely not.  Tiff files may hold a full image in IFD1 and while I haven't tested it with regards to RAW files, it's not something I would depend upon.

The best way would be to simply use
exiftool -ThumbnailImage= /path/to/files/

This will get rid of the ThumbnailImage which is the majority of the excess size and anything left behind will take up only minimal space.

Or to get rid of any embedded preview images (PreviewImage, JpgFromRaw)
exiftool -Preview:All= /path/to/files/

QuoteAs an alternative, I noticed when recreating tags with the command below, the thumbnail is not copied over (as the filesize noticeably decreases), however all the EXIF:IFD1 tags were copied over,

I'm not sure what the exact rules regarding ThumbnailImage are, whether it is "Avoid" or "Protected" or something else.  I can't really find the correct listing among the tag names (so many groups contain a ThumbnailImage).  But basically it will not be copied unless specially listed.  Actually, I think it may be "Unsafe".

Quoteexiftool -r -overwrite_original -all= -tagsfromfile @ -all:all FILEorDIR

Second question, is this -tagsfromfile approach preferred over the first as it keeps all the tags?

Yes, sort of.  Using -TagsFromFile @ -All:All will copy most tags back into the file. But it will not copy any tags marked as "Unsafe".  From the Tags Names page
QuoteAn exclamation point (!) indicates a tag that is considered Unsafe to write under normal circumstances. These tags are not written unless specified explicitly (ie. not when wildcards or "all" are used), and care should be taken when editing them manually since they may affect the way an image is rendered.

I think this includes the ThumbnailImage but also of import is that the ICC_Profile is also marked "Unsafe". FAQ #20 is worth reading on this.

QuoteThird question, can either approach be used to remove thumbnails from tifs, or is it safer to leave the tif thumbnail intact, as is recommended for dng and raw?

As above, it's probably not a good idea, as a tiff may include a full image in any IFD#.  I would think its uncommon, though.
* 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).

aperturemode