Cannot successfully remove embedded thumbnail from TIFF

Started by timmy2, May 25, 2016, 01:17:35 AM

Previous topic - Next topic

timmy2

I want to use some 16-bit TIFF files with Enfuse.  These TIFF files are output by Nikon's Capture NX-D from original NEF files.  The problem for Enfuse is that the Capture program adds an 8-bit Thumbnail to the TIFF.

I assume the presence of this thumbnail is why I see an IFD1 section in ExifToolGUI. I've tried the "Remove metadata > -Exif:IFD1" option in ExifToolGUI and it returns an error in the log window: "Error: [minor] Deleting IFD1 also deletes subsequent IFD's and possibly image data".  I've tried using the ExifTool direct function to issue -ThumbnailImage= but the log says nothing was changed.

Can anyone tell me a sure-fire way to find and remove this 8-bit Thumbnail?

StarGeek

FAQ 7 explains why you can't remove all the metadata from a Tiff file.

Try running the command in FAQ 3 to figure out what the actual name of the thumbnail image might be.  Look for items like TIFFPreview or PreviewImage and test to see if those are what you want to remove.
* 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).

timmy2

Quote from: StarGeek on May 25, 2016, 02:27:19 AM
FAQ 7 explains why you can't remove all the metadata from a Tiff file.

Try running the command in FAQ 3 to figure out what the actual name of the thumbnail image might be.  Look for items like TIFFPreview or PreviewImage and test to see if those are what you want to remove.

Thank you for replying, StarGeek. Very much appreciated.  I piped the output of "exiftool -a -G1 -s > report.txt" to a text file and found no instances of TiffPreview. But I did find several occurrences of PreviewIFD:

[PreviewIFD]    Compression                   : JPEG (old-style)
[PreviewIFD]    XResolution                     : 300
[PreviewIFD]    YResolution                     : 300
[PreviewIFD]    ResolutionUnit                 : inches
[PreviewIFD]    PreviewImageStart          : 67392
[PreviewIFD]    PreviewImageLength       : 203436

...and one occurrence of "PreviewImage" in the left column, where the details to the right say "Binary data 223362 bytes, use -b option to extract".

Please know that here I am merely a keyboard monkey (sorry about the insult to monkeys who might be reading this), with next to no understanding of what I'm doing in ExifTool (thus my use of the ExifToolGUI).  But I can follow explicit instructions.

Given the above information is there a way to remove the thumbnail (if indeed the above is the thumbnail that's tripping up Enfuse) and save the resulting changed file?


StarGeek

Quote from: timmy2 on May 25, 2016, 03:26:47 PM
...and one occurrence of "PreviewImage" in the left column, where the details to the right say "Binary data 223362 bytes, use -b option to extract".

That would probably be your thumbnail that you're looking for.  Use -PreviewImage= as the Exiftool direct command in the gui or on the command line you can use
Exiftool -PreviewImage= FileOrDir
* 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).

timmy2

Quote
Quote
    Quote from: timmy2 on Today at 12:26:47

        ...and one occurrence of "PreviewImage" in the left column, where the details to the right say "Binary data 223362 bytes, use -b option to extract".

    That would probably be your thumbnail that you're looking for.  Use -PreviewImage= as the Exiftool direct command in the gui or on the command line you can use
    Exiftool -PreviewImage= FileOrDir

Thank you for replying so quickly!  I converted one of the files but I'd like to verify that the thumbnail was removed. Using ExifToolGUI I see that the modified file still contains the IFD1 metadata that was in the originals. Using the command you referred me to previously (exiftool -a -G1 -s) all the original [PreviewIFD] metadata is also still present, BUT -- and this may be the key -- there is now no occurrence of PreviewImage, unlike before. Is that sufficient proof? (I know, I know, I could just run these through Enfuse and see if it fails, but I'm not at the PC that has Enfuse.)

Thank you again, StarGeek!

StarGeek

Oops, sorry, I messed up and replaced your post with my response, that's why your post now says edited.  Sorta fixed now.

If it doesn't show up in Exiftool, then it's gone.  There may be other things that Enfuse doesn't like, so you'll have to double check with that program.

Any thumbnails are going to be binary data and is going to have the "Binary data #### bytes, use -b option to extract" info on it.  The IFD1 tags are part of an Image File Directory of the EXIF block.  In a Tiff file, I believe that this is where the actual image data is going to be.  It shouldn't cause a problem.   I shouldn't think that the PreviewIFD section should cause a problem with the actual preview image removed, but if it does, you can remove it as well with -PreviewIFD:all=.

* 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).

timmy2

Quote from: StarGeek on May 25, 2016, 05:40:09 PM
... shouldn't think that the PreviewIFD section should cause a problem with the actual preview image removed, but if it does, you can remove it as well with -PreviewIFD:all=.

Thank you for your guidance, StarGeek.

Alas, Enfuse still aborts upon encountering the first picture in the list of TIFFs for it to blend.  The error log says:

Quoteenfuse: warning: ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations
enfuse: info: input image "_DSC3642.tif", layer 1/2 does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image
enfuse: info: input image "_DSC3642.tif", layer 2/2 does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image
enfuse: input image "_DSC3642.tif", layer 2/2 has pixel type UINT8,
enfuse:   but previous images have pixel type UINT16

These errors are the same as what I got when I use a TIFF not processed by ExifTool, so removing the thumbnail binary (?) had no effect.

All I can decipher from the errors is confirmation that Enfuse is seeing an 8-bit layer (the thumbnail) along with a 16-bit one (the actual image).  Could Enfuse be rejecting the file based on metadata and not the actual image(s)?

I tried your suggested -PreviewIFD:all= but it returned an error, "Warning: Not a deletable group: PreviewIFD. Nothing to do."

I opened in Photoshop CS6 the same TIFF file that Enfuse choked on, immediately saved it as a TIFF copy, and Enfuse had no problem with it!  So there' something that Nikon Capture NX-D is adding to the 16-bit TIFF that Photoshop removes automatically.

Hmm.  I wonder if comparing an ExifTool dump of the Capture NX-D TIFF (the offending one) to an ExifTool dump of the Photoshop copy would help, or would I just be told the differences are not deletable?

Ah well, I'll seek a different approach after my head clears. Thank you very much for your efforts.

Phil Harvey

So what happened when you did this?: exiftool -ifd1:all= -m FILE

Did enfuse still find 2 layers?

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

timmy2

WOW, that did it!  ;D

Thank you, Phil.  A warning is issued but the file is processed.

Quote-ifd1:all= -m DSC65_001NVNXi.TIF
Warning: Deleting IFD1 also deletes subsequent IFD's and possibly image data - DSC65_001NVNXi.TIF
    1 image files updated

And Enfuse processes the file without aborting. The log shows some issues but apparently none of them are fatal.

Quoteenfuse: warning: ASCII value for tag "DateTime" contains null byte in value; value incorrectly truncated during reading due to implementation limitations
enfuse: info: input image "DSC65_001NVNXi.TIF" does not have an alpha channel;
enfuse: info: assuming all pixels should contribute to the final image

I greatly appreciate your help (and also that of StarGeek).

timmy2

For future readers note that there is no need to use the  -PreviewImage= in order to get Enfuse to accept the 16-bit TIFF files.  The only command needed is -ifd1:all=

Also, note that this process is needed regardless of whether you use Nikon Capture NX-D or ViewNX-i to convert files from NEF to 16-bit TIFF. Apparently both add the 8-bit thumbnail that causes Enfuse to choke.

olball

Or add [1] to filename so select only the first layer:
enfuse file1.tif[1] file2.tif[1]..

see section 4.5 "layer selection" of the enfuse manual.

timmy2

Quote from: olball on May 26, 2016, 11:50:39 AM
Or add [1] to filename so select only the first layer:
enfuse file1.tif[1] file2.tif[1]..

see section 4.5 "layer selection" of the enfuse manual.

OMG, after all that messing around with ExifTool, you, olbol, reveal an alternate solution. Thank you!

Because I;ve only used EnfuseGui I know nothing about using Enfuse from the command line. It took some experimenting and reading the PDF, but I think I'm close -- maybe as close as I'll ever get. 

Here's what generated a blended tiff from 7 bracketed TIFFs in the enfuse folder:

Quoteenfuse --output=test.tif --verbose --layer-selector=first-layer *.tif

Also generated were a bunch of these warnings:

QuoteWarning: TIFFDecoder: no TIFFTAG_SAMPLEFORMAT or TIFFTAG_DATATYPE, guessing pixeltype 'UINT16'.

I tried again with --depth=uint16 added but the same warnings appear.  Am I leaving out a necessary command line parameter?


Also, for every filename processed there were these two messages (in addition to more of the above warnings):

Quoteenfuse: info: input image "NT1.tif", layer 1/2 does not have an alpha channel;
enfuse: note: assuming all pixels should contribute to the final image

I saw the above messages back when EnfuseGUI aborted upon encountering the 8-bit thumbnail inside the TIFF file, so apparently Enfuse issues those messages and then ignores the thumbnail layer because of the --layer-selector command.

Thanks again, olbol. If you have any suggested refinements they'll be welcome!