Extract JPG from DNG

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
graemeNPS
Posts: 64
Joined: 2009-01-12T14:25:55-07:00

Extract JPG from DNG

Post by graemeNPS »

I am trying to extract a jpg thumbnail and a jpg resized image from a DNG file by calling Imagemagick (v6.3.4 - Windows) from a running program to do the conversion.

I am using a command similar to the following (also tested on the command line, same result):
>convert cpySrc.dng -auto-orient -colorspace RGB -flatten -thumbnail 1024x1024 test.jpg
but the output, test.jpg, is blurred when I do this; this command seems to give me a up-scaled version of the embedded jpeg preview; the original dng is about 2900x4500 pixels.

I have tried:
>convert dng:cpySrc.dng dng_testdng.jpg
but the result does not look like the preview image at all.

When I run:
>convert cpySrc.dng testdng.jpg
the result is a 171x256 pixel jpg image, which is useable for the thumbnail image I require.

In short, I can extract the thumbnail OK, but the resized image does not extract correctly from the source image for a best-fit for a 1024x1024 resize request.

Do you have any suggestions for a command line that may solve this problem?
weshysell

Re: Extract JPG from DNG

Post by weshysell »

I know this is an old post, but due to the lack of support for the users, I find it necessary to respond with my findings.

When you use:

Code: Select all

convert cpySrc.dng -auto-orient -colorspace RGB -flatten -thumbnail 1024x1024 test.jpg
The convert tool treats the cpySrc.dng as a TIFF file, which will read from IFD0 (according to specifications), this is a small-scaled thumbnail. There can be several thumbnails inside the TIFF specification, and apparently ImageMagick doesn't support retrieving these individual thumbnails at all.

When you tried:

Code: Select all

convert dng:cpySrc.dng dng_testdng.jpg
The convert tool recognizes cpyCrs.dng as a DNG file because you explicitly casted it as such with the dng: prefix. However, this returns the RAW data. In a DNG file (according to specifications), the DNG contains the RAW data that your camera captured, without modifications. When you modify the settings of the pictures (such as tone, tint, exposure, etc), those settings are stored and applied on the fly when you open that file. When you are satified with the settings, you software (generally Adobe Camera Raw or Adobe Lightroom) applies these changes to the thumbnails. In conclusion, when you explicitly cast the file as DNG, you are retrieve the original camera data, and not your alterations. This is why storing a full-size embedded JPEG is important (see "Preferences" in Adobe Camera Raw -- I believe it defaults to medium-sized).

When you tried:

Code: Select all

convert cpySrc.dng testdng.jpg
As mentioned, this treats it as a TIFF, which pulls out only the smaller thumbnail (max size 256 in either direction, with a locked aspect ratio for the other dimension).

-----

So the REAL suggestion would be to have ImageMagick show support for retrieving these thumbnails straight out of the DNG files AND the other RAW formats (most notably, CR2's and NEF's).

Sorry, I wish I had an answer, I have been trying to figure out a solution myself for IMagick (PHP API for ImageMagick) for a few weeks now, and have no solution.

-- Wes
Post Reply