3 Replies Latest reply on Jan 8, 2014 7:44 AM by rob day

    Extract embedded images from an idml file using idmltools library

    avsrivas Level 1

      Hi,

       

      I need to extract all the embedded images present in an idml file and write all the images in a different folder in jpeg/png format.

       

      I have extracted the text contents of the Contents node present for an embedded image in a java string, so basically I have the CDATA for each image, but I don't know from here how to proceed to write the image using this data.

       

      Will I need to extract values of other nodes as well along with some attributes to reconstruct the images and write them to a folder?

      How can I decode the CDATA ( also the cases which have multiple blocks of CDATA for an image) to reconstruct the image?

       

      I am using the idmltools library for this task.

       

      Thanks,

      Avinash

        • 1. Re: Extract embedded images from an idml file using idmltools library
          Laubender Adobe Community Professional & MVP

          @Avinash – I'd use InDesign (the re-opened IDML file) and some ExtendScript scripting for that task.
          You have to distinguish between three basic data types:

           

          1. Pixel only

          2. Vector only

          3. Mixed pixels and vector

           

          Pixel only: could stem from a variety of source files: from PSD, TIFF, JPEG, PNG, EPS…
          Vector only: EPS, WMF, PDF

          Mixed ones: EPS, PDF, PhotoShop (//EDIT: Not to forget PSD!!)

           

          It depends on your InDesign version which type of file you can write (export):

          PDF, EPS, JPEG, PNG*

           

          So, for an unclear situation (the nature of the placed file) I always would chose PDF as export format with transparency intact: PDF/X-4.


          And proceed on with the exported PDFs. You could parse them to PhotoShop writing pure pixel formats if you want.
          You could also look for Adobe Illustrator meta data and try to open it in Adobe Illustrator.

           

          Here an example for what can be done with ExtendScript and pasted or embedded images by Peter Kahrel:

           

          Peter Kahrel

          Write pasted and embedded images to disk

          http://www.kahrel.plus.com/indesign/unembed_images.html

           

          However, this script is missing PDFs as export format.
          Layered embedded PhotoShop or Adobe Illustrator files would also be a very special case that should be treated separately.

          Color Management in these cases could be a problem too.

           

          From pure IDML, I see no chance…
          (but maybe someone else)

           

          Uwe

           

          Message was edited by: Laubender

          • 2. Re: Extract embedded images from an idml file using idmltools library
            rob day Adobe Community Professional & MVP

            I'm not sure if this will help, but pasted or embedded objects are copied to the clipboard with all of their info as PDF if the Copy PDF to Clipboard is checked in the Clipboard Handling preference. In that case all of the embedded file info including transparancy is on the clipboard and can be resaved and linked via scripting. Here's an Applescript example that relinks pasted or embedded files as PDFs.

             

            http://www.zenodesign.com/forum/LinkPasted.zip

            • 3. Re: Extract embedded images from an idml file using idmltools library
              rob day Adobe Community Professional & MVP

              Color Management in these cases could be a problem too.

               

              The clipboard does not include an embedded file's profile, so the clipboard script links the PDF back without a profile. It would be the same as having your CM Policy set to Preserve Numbers