verifying and rebuilding full-size JPEG previews in DNG

Started by Archive, May 12, 2010, 08:54:02 AM

Previous topic - Next topic

Archive

[Originally posted by setuporg on 2007-04-08 20:28:55-07]

How can one verify that a DNG file contains a full-size JPEG preview, and, if not, rebuild it from command-line?

Archive

[Originally posted by exiftool on 2007-04-09 11:55:24-07]

In a DNG, the previews are stored in SubIFD1 and SubIFD2, so you can check to
seeYou can check the sizes of the images in the SubIFD1 and SubIFD2 to see
if the full-sized preview exists:

Code:
exiftool -subifd1:imagewidth -subifd1:imageheight -subifd2:imagewidth -subifd2:imageheight -G1 image.jpg

But currently you can't use exiftool to add preview images to a DNG.

- Phil

Archive

[Originally posted by exiftool on 2007-04-09 12:11:20-07]

I'm sorry.  After reading your mail I realized that you don't want to add
a new preview image, but only regenerate an existing preview.  You must
use another utility to generate the preview, but you can use exiftool to
update it in the DNG:

First you have to decide if you want to write the PreviewImage (SubIFD1)
or the JpgFromRaw image (SubIFD2) if it exists. Normally the JpgFromRaw
is the larger of the two, so if it exists you should use it for a full-sized
preview.  But assuming it doesn't exist, you could update the PreviewImage
with a command line like this:

Code:
exiftool "-previewImage<=preview.jpg" -tagsfromfile preview.jpg \
          "-subifd1:imagewidth<imagewidth" "-subifd1:imageheight<imageheight" image.dng

- Phil

Archive

[Originally posted by setuporg on 2007-04-09 18:56:56-07]

Cool.  I was playing with File Juicer,

http://echoone.com/filejuicer/" target="_blank">http://echoone.com/filejuicer/

-- to extract the reviews for verification.  Interestingly, running the above command yields different results.  I supply two files, a.DNG and b.dng, and their resulting "a Juice" and "b Juice" folders in

http://photobeauty.com/tarballs/dng-full-size-jpeg-preview-research.tar.bz2" target="_blank">http://photobeauty.com/tarballs/dng-full-size-jpeg-preview-research.tar.bz2

(TIFFs, 58 MB each, deleted from the Juice's)

a.DNG is a K10D native DNG edited in Adobe Lightroom 1.0.  As we know, LR doesn't regenerate full-size previews, which is its main problem for DNG-based workflow for now.  This is what I'm overcoming with Adobe DNG Converter workaround.
b.dng is the result of running Adobe DNG Converter on the above DNG (where LR edits are pushed back as XMP into the DNG), with the setting to generate full-size JPEG previews.

exiftool -subifd1:imagewidth -subifd1:imageheight -subifd2:imagewidth -subifd2:imageheight -G1 a.DNG
[SubIFD1]       Image Width                     : 3872
[SubIFD1]       Image Height                    : 2592

-- at the same time, exploring "a Juice" in Finder shows:

a-1.jpg => 3872x2592, size: 1.2 MB
a-2.jpg => 3856x2576, size: 2.6 MB
a.jpg => 640x480, size: 24 KB

-- notice that exiftool didn't report a-2.jpg which is the full-size (left from K10D? since LR is not supposed to regenerate it).  So it's not subifd2!

Similarly, for a.dng we see:

exiftool -subifd1:imagewidth -subifd1:imageheight -subifd2:imagewidth -subifd2:imageheight -G1 b.dng
[SubIFD1]       Image Width                     : 1024
[SubIFD1]       Image Height                    : 685
[SubIFD2]       Image Width                     : 3872
[SubIFD2]       Image Height                    : 2592

Juice:

b-1.jpg => 1024x685, size: 52 KB
b-2.jpg => 3872x2592, size: 1.3 MB
b-3.jpg => 3920x2608, size: 2.7 MB
b.jpg => 640x480, sizeL 24 KB

-- subifd2 is now present, but the biggest-size preview is not reported by exiftool!

Notice that the biggest previews are not reported by exiftool at all -- nothing with those dimensions.

Perhaps FileJuicer makes some assumptions -- e.g., it produces 58 MB TIFFs in both cases which I deleted from the Juice's?

But why the discrepancy, and how can one, in addition to dimensions, get the *size* of the previews?  Browsing through DNG tags shows there are some tags for preview sizes in MakerNotes -- but the amount of tags is staggering, so I'm not sure which ones are suitable for size extraction; and maker notes' seem to relate to out-of-camera ones, what would be the way to get size for the previews generated by Adobe DNG Converter?

Cheers,
Alexy

Archive

[Originally posted by exiftool on 2007-04-09 19:24:01-07]

Hi Alexy,

Look at the PreviewImageLength and JpgFromRawLength for the sizes of the PreviewImage and JpgFromRaw image.

Code:
> exiftool dng-full-size-jpeg-preview-research -previewimagelength -jpgfromrawlength -a -G1
======== dng-full-size-jpeg-preview-research/a.DNG
[SubIFD1]       Preview Image Length            : 1242392
[Pentax]        Preview Image Length            : 24042
========dng-full-size-jpeg-preview-research/b.dng
[SubIFD1]       Preview Image Length            : 52249
[Pentax]        Preview Image Length            : 24042
[SubIFD2]       Jpg From Raw Length             : 1403172
    1 directories scanned
    2 image files read

Juicer must be converting the raw data to get the larger JPEG image because I am pretty sure
that image doesn't exist in the DNG.  The 640x480 preview exists in the Pentax maker notes
and is separate from the preview(s) generated by Adobe DNG converter.

- Phil

Archive

[Originally posted by exiftool on 2007-04-09 19:42:41-07]

Ah.  I know where Juicer gets the large "JPEG".  It is the image stored in the 0th
SubIFD.  But this image isn't stored as a standalone JPEG file, so ExifTool won't
extract it.  In fact, it seems to be more of a compressed version of the raw sensor
output rather than a JPEG image (it is 16 bits and one color per pixel, as opposed
to 8 bits x 3 colors for your standard JPEG image).

- Phil

Archive

[Originally posted by setuporg on 2007-04-09 20:25:33-07]

An interesting thing is that that "largest" (~2.5 MB) JPEG differs between a.DNG and b.dng -- so Adobe DNG Converter (ADC) apparently touches/affects it, and Juicer produces different results!  The dimensions and sizes are different.

a-2.jpg: 3856x2576, size: 2.6 MB

b-3.jpg: 3920x2608, size: 2.7 MB

And Finder shows it in color -- RGB, not B&W.  However, since I adjusted the tones in LR, the "legit" previews are corrected in b.dng, while these big ones stays the same dull color.

I guess if it's not jpegfromraw than iView etc. won't even use it, but the puzzlement as to why it changed sizes after ADC remains.  https://exiftool.org/forum/Smileys/default/smiley.gif" alt="Smiley" border="0" />