3 Replies Latest reply on Jan 22, 2009 1:06 PM by (Graeme_Elliott)

    Extracting JPEG preview image from DNG file

    Level 1
      My company is using the DNG SDK to support raw or DNG files for users of our digital asset management software. We extract a jpeg preview/thumbnail from ALL file types we support.
      My question is: how can we extract a jpeg preview from a DNG file, using the latest version of the DNG SDK?
      Currently, our software uses the SDK to read a DNG file and write a tiff file, and passes the tiff to imagemagick to get a resized jpeg we can use for a preview or thumbnail.
      When we extract the tiff from the customer's file, we get a base version of the image that does not show subsequent colour adjustments made in (eg) CS3; the customer would like to get a preview that shows (especially) the colour adjustments that have been made.
      I know the jpeg preview exists inside the DNG, I used exiftools to extract it,and it does show the colour adjustments made.
      How do I get that preview image out of the DNG file using the DNG SDK? Does the DNG SDK support that operation?

      The SDK has a lot of API, but not much documentation or samples to show usage.

      Thanks for any help anyone can provide.
        • 1. Re: Extracting JPEG preview image from DNG file
          m_p_bailey Level 1
          I don't know about the DNG SDK, but I know that ExifTool can do this. You can run it as a command line executable, or use the underlying Perl module directly. There are also third-party GUI tools to wrap round it. Very useful for all sorts of stuff.

          All that assumes that the DNG already has a JPEG preview to extract, of course.
          • 2. Re: Extracting JPEG preview image from DNG file
            Level 1
            Maybe it isn't the smartest way, but this should work:<br /><br />... call info.Parse (host, stream) etc here - the usual stuff<br />{<br />     // find biggest jpeg image for preview<br />     unsigned int subMaxW=0;<br />     int subMaxI=-1;<br />     for(unsigned int i=0;i<info.fIFDCount;i++)<br />     {<br />          dng_ifd* pIFD=info.fIFD[i].Get();<br />          if (ccJPEG==pIFD->fCompression && 1==pIFD->fNewSubFileType)<br />          {<br />               if (pIFD->fImageWidth>subMaxW)<br />               {<br />                    subMaxW=pIFD->fImageWidth;<br />                    subMaxI=i;<br />               }<br />          }<br />     }<br />     if (subMaxI>=0) // load desired jpeg preview<br />     {<br />          unsigned int i=subMaxI;<br /><br />          dng_ifd* pIFD=info.fIFD[i].Get();<br />          if (ccJPEG==pIFD->fCompression && 1==pIFD->fNewSubFileType)<br />          {<br />               // seek to pIFD->fTileOffset[0] and load jpeg<br />          }               <br />     }<br />}