Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Preview & Thumbnail from Nilon RAW Nef file #692

Open
MaximeOh opened this issue Jan 29, 2025 · 0 comments
Open

Extract Preview & Thumbnail from Nilon RAW Nef file #692

MaximeOh opened this issue Jan 29, 2025 · 0 comments

Comments

@MaximeOh
Copy link

I try to extract thumb & preview image from a Nikon RAW file.
For my test i use a lot of file from this bank.

I analyze all the exif tag with exiftool and i found some important things, there is 3 jpg images inside.

ExifIFDO

The image in IFD0 (determined by Strip Offsets & Strip byte counts) is not a jpg file and seems empty (a lot of zero inside).

ExifSubIFD

Exif tool tell me there is a small JPEG inside.

--- Exif Tool out ---
Jpg From Raw Start              : 1050112
Jpg From Raw Length             : 1216696
Jpg From Raw                    : (Binary data 1216696 bytes, use -b option to extract)

When i compare with extracted data via metadata-extractor, i have two tags in this directory, with the same values, but this tag is unknown by metadata-extractor.

----Metadata out - Exif SubIFD-----
Unknown tag (0x0201) : 1050112
Unknown tag (0x0202) : 1216696

But the code 0x0201 & 0x0202 are used in other Directory by metadata-extractor, in the ExifThumbnailDirectory class

  /**
     * The offset to thumbnail image bytes, relative to the start of the IFD.
     *
     * To obtain the offset relative to the start of the TIFF data stream, use
     * <code>getAdjustedThumbnailOffset</code>, which includes the value of
     * <code>getExifStartOffset</code>.
     */
    public static final int TAG_THUMBNAIL_OFFSET = 0x0201;
    /**
     * The size of the thumbnail image data in bytes.
     */
    public static final int TAG_THUMBNAIL_LENGTH = 0x0202;

So i can retrieve this values in my ExifSubIFDDirectory with ExifThumbnail constants :

ExifSubIFDDirectory exifSubDir =  ...
int offset = exifSubDir.getInt(ExifThumbnailDirectory.TAG_STRIP_OFFSETS);
int length = exifSubDir.getInt(ExifThumbnailDirectory.TAG_STRIP_BYTE_COUNTS);

Exif SubIFD Again

Yes, there are another dictionary with the same unknown tags (0x0201 & 0x0202).
I can extract it, cool.

-----Metadata out - Exif SubIFD----
New Subfile Type : Reduced-resolution image
Compression : JPEG (old-style)
X Resolution : 300 dots per inch
Y Resolution : 300 dots per inch
Resolution Unit : Inch
Unknown tag (0x0201) : 235520
Unknown tag (0x0202) : 814184
YCbCr Positioning : Datum point

Exif SubIFD Not a Jpg

i found another image, but it's not a jpg, maybe a tiff.

---- Metadata out - Exif SubIFD---
New Subfile Type : Full-resolution image
Image Width : 5584 pixels
Image Height : 3728 pixels
Bits Per Sample : 14 bits/component/pixel
Compression : Uncompressed
Photometric Interpretation : Color Filter Array
Strip Offsets : 2267136
Samples Per Pixel : 1 samples/pixel
Rows Per Strip : 3728 rows/strip
Strip Byte Counts : 41634304 bytes
X Resolution : 300 dots per inch
Y Resolution : 300 dots per inch
Planar Configuration : Chunky (contiguous for each subsampling pixel)
Resolution Unit : Inch
CFA Repeat Pattern Dim : 2 2
CFA Pattern : [Red,Green][Green,Blue]
Unknown tag (0x9217) : 2

And the preview?

Yes, exiftool tell me there are a PreviewIFD

---- ExitTool out - PreviewIFD ----
Compression                     : JPEG (old-style)
X Resolution                    : 300
Y Resolution                    : 300
Resolution Unit                 : inches
Preview Image Start             : 52164
Preview Image Length            : 124762
Y Cb Cr Positioning             : Co-sited
Preview Image                   : (Binary data 124762 bytes, use -b option to extract)

Best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant