16 Replies Latest reply on Dec 10, 2009 1:14 PM by AdobeScripts

    [AS] how to get XMP data

    Kevin Parrott Level 2

      Hi

       

      I am wanting to get the swatches used in a document via the XMP raw data info using applescript, can some one please explain to me how to do this.

       

      This is how the data is shown in the Raw Data window:

       

        <xmpG:swatchName>PANTONE Warm Red U</xmpG:swatchName>

       

      this is the result I am after:

       

      PANTONE Warm Red U

       

      cheers
      Kev

        • 1. Re: [AS] how to get XMP data
          sstanleyau Level 4

          Set AS's text item delimiters to "<xmpG:swatchName>" and get text item 2, then set them to "</xmpG:swatchName>" and get text item 1 of the result.

          1 person found this helpful
          • 2. Re: [AS] how to get XMP data
            Kevin Parrott Level 2

            Hi Shane

             

            thanks for that, Im not sure if I have set this up correctly as I seem to be getting only "<xmpG:swatchName>" returned.

             

             

            --try
            set oldDelims to AppleScript's text item delimiters
            set AppleScript's text item delimiters to "<xmpG:swatchName>"
            set _Item2 to text item 2 of the result

             

            set AppleScript's text item delimiters to "</xmpG:swatchName>"
            set _Item1 to text item 1 of the result

             

            set AppleScript's text item delimiters to oldDelims
            --on error
            --set AppleScript's text item delimiters to oldDelims
            --end try

            • 3. Re: [AS] how to get XMP data
              sstanleyau Level 4

              Try this:

               

              set theData to "<xmpG:swatchName>PANTONE Warm Red U</xmpG:swatchName>"

              set oldDelims to AppleScript's text item delimiters

              set AppleScript's text item delimiters to {"<xmpG:swatchName>"}

              set partData to text item 2 of theData

              set AppleScript's text item delimiters to {"</xmpG:swatchName>"}

              set swatchName to text item 1 of partData

              set AppleScript's text item delimiters to oldDelims

              return swatchName

              • 4. Re: [AS] how to get XMP data
                Kevin Parrott Level 2

                ahh,I see, that works a treat, I think im not explaining my self to clearly, the result is what I want but I need that result to come directly

                from the XMP metadata, see attached, is thie possible? with applescript, if so how would I go about it?

                • 5. Re: [AS] how to get XMP data
                  sstanleyau Level 4

                  I don't believe you have scripting access to that XMP metadata, other than perhaps parsing the file yourself.

                  • 6. Re: [AS] how to get XMP data
                    Kevin Parrott Level 2

                    ive done some goggleing around an come up with this cool commnd line tool called ExifToll from here   http://www.sno.phy.queensu.ca/~phil/exiftool/


                    which gets the info out of indesign, but now I cant figure out how to extract what I need from the result given.

                     

                    Exif Tool needs to be installled to run this:

                     

                    set p2f to "/Users/kevin/Desktop/Q70233-PROOF" --POSIX path to file
                    do shell script "/usr/bin/exiftool -XMP -b" & space & quoted form of p2f

                     

                     

                    Kev

                    • 7. Re: [AS] how to get XMP data
                      Kevin Parrott Level 2

                      ive managed to get one colour from the XMP data, how would i go about getting the rest?

                       

                       

                       

                       

                      set theData to "               <rdf:li rdf:parseType=\"Resource\">
                                        <xmpG:swatchName>Black</xmpG:swatchName>
                                        <xmpG:mode>CMYK</xmpG:mode>
                                        <xmpG:type>Process</xmpG:type>
                                        <xmpG:cyan>0</xmpG:cyan>
                                        <xmpG:magenta>0</xmpG:magenta>
                                        <xmpG:yellow>0</xmpG:yellow>
                                        <xmpG:black>100</xmpG:black>
                                     </rdf:li>
                                     <rdf:li rdf:parseType=\"Resource\">
                                        <xmpG:swatchName>Keyline</xmpG:swatchName>
                                        <xmpG:mode>CMYK</xmpG:mode>
                                        <xmpG:type>Spot</xmpG:type>
                                        <xmpG:cyan>0</xmpG:cyan>
                                        <xmpG:magenta>100</xmpG:magenta>
                                        <xmpG:yellow>0</xmpG:yellow>
                                        <xmpG:black>20</xmpG:black>
                                     </rdf:li>
                                     <rdf:li rdf:parseType=\"Resource\">
                                        <xmpG:swatchName>Paper</xmpG:swatchName>
                                        <xmpG:mode>CMYK</xmpG:mode>
                                        <xmpG:type>Process</xmpG:type>
                                        <xmpG:cyan>0</xmpG:cyan>
                                        <xmpG:magenta>0</xmpG:magenta>
                                        <xmpG:yellow>0</xmpG:yellow>
                                        <xmpG:black>0</xmpG:black>
                                     </rdf:li>
                                     <rdf:li rdf:parseType=\"Resource\">
                                        <xmpG:swatchName>Registration</xmpG:swatchName>
                                        <xmpG:mode>CMYK</xmpG:mode>
                                        <xmpG:type>Process</xmpG:type>
                                        <xmpG:cyan>100</xmpG:cyan>
                                        <xmpG:magenta>100</xmpG:magenta>
                                        <xmpG:yellow>100</xmpG:yellow>
                                        <xmpG:black>100</xmpG:black>
                                     </rdf:li>
                                  </rdf:Seq>
                               </xmpTPg:Colorants>
                               <xmpTPg:Fonts>
                                  <rdf:Bag>"

                       

                      set oldDelims to AppleScript's text item delimiters

                       

                      set AppleScript's text item delimiters to {"<xmpG:swatchName>"}

                       

                      set partData to text item 2 of theData

                       

                      set AppleScript's text item delimiters to {"</xmpG:swatchName>"}

                       

                      set swatchName to text item 1 of partData

                       

                      set AppleScript's text item delimiters to oldDelims

                       

                      return swatchName

                      • 8. Re: [AS] how to get XMP data
                        sstanleyau Level 4

                        The best way would be to use one of the third-party XML scripting additions. Is it only a list of colors used you're after? Because this looks the hard way of gathering that...

                        • 9. Re: [AS] how to get XMP data
                          Kevin Parrott Level 2

                          yeah, im basically after a list of used colours from the document,

                           

                          where do I get the XML scripting additions from Shane.

                          • 10. Re: [AS] how to get XMP data
                            sstanleyau Level 4

                            If all you want is the colors, you can use "delete unused swatches" and then get the name of every swatch ("unused swatches" is a document property). If you need colors that don't appear in the Swatches panel, you can get every color, and check the actual color used for the unnamed ones.

                             

                            For XML additions, search on Late Night Software and Satimage.

                            1 person found this helpful
                            • 11. Re: [AS] how to get XMP data
                              Kevin Parrott Level 2

                              cheers for the input Shane, I already use the suggested, but have found it to be a bit flaky, meaning that if I have a colour say "BOBS COLOUR" then it will show as such, and if I map that colour through ink manager it still shows as bobs colour, so I thought by getting the XMP data that the mapped colour would show, also I found that colours used in gradients some times did not show when they should, also noted that even when black was not used in a document it would still show up in the list of used colurs, so I had to write a work around for that which is flaky to say the least.

                              Basically im looking for a rock solid way to identify and show the colours used in my doc.

                               

                               

                              Kev

                              • 12. Re: [AS] how to get XMP data
                                AdobeScripts Level 3

                                hi Kevin,

                                 

                                Why you need to know which color is used in your document ?

                                To delete it - to clean your document or what ?

                                Or are you talking about Inks and number of separations ?

                                 

                                robin

                                www.adobescripts.co.uk

                                • 13. Re: [AS] how to get XMP data
                                  Kevin Parrott Level 2

                                  Hi Robin

                                   

                                  I need to obtain used colour names, and if one of those colours is mapped obtain it's mapped colour name to use in slug information, so my clients can see what colours are
                                  being used in their document, ideally I would like to also show a colour chip next to the colour.

                                   

                                  At the moment my slug information via scripting contains:
                                  job description, date and time stamp, document size, number of pages and few other bits and bobs, having the colours used would complete this information.

                                   

                                  Kev
                                  • 14. Re: [AS] how to get XMP data
                                    AdobeScripts Level 3
                                    I need to obtain used colour names, and if one of those colours is mapped obtain it's mapped colour name to use in slug information, so my clients can see what colours are
                                    being used in their document, ideally I would like to also show a colour chip next to the colour.

                                    There is workaround maybe not very elegant but working

                                    You need to print separation - with only one ink selected and set false to PrintBlankPages

                                    If you get error on myDoc.PrintOut - your ink is not used

                                     

                                    robin

                                    www.adobescripts.co.uk

                                    • 15. Re: [AS] how to get XMP data
                                      Kevin Parrott Level 2

                                      I might be  a bit slow o the uptake this morning, can you explain a bit more please?

                                      • 16. Re: [AS] how to get XMP data
                                        AdobeScripts Level 3

                                        I might be  a bit slow o the uptake this morning, can you explain a bit more please?

                                         

                                        working example (VB):

                                         

                                        Dim myindi As InDesign.Application
                                        Dim mydoc As InDesign.Document

                                        Dim myPrinterPreset As InDesign.PrinterPreset
                                        Set myindi = CreateObject("indesign.application.CS3")
                                        Set mydoc = myindi.ActiveDocument
                                               
                                        Set myPrinterPreset = myindi.PrinterPresets.Item(1)

                                         

                                        With myPrinterPreset

                                            .PrintBlankPages = False
                                            .ColorOutput = idColorOutputModes.idSeparations
                                            .PrintCyan = True
                                        End With
                                           
                                        On Error Resume Next
                                        Call mydoc.PrintOut(False, myPrinterPreset)

                                        If Err.Number <> 0 Then

                                            ' no file created - Ink not used

                                        End If
                                        On Error GoTo 0

                                         

                                        robin

                                        www.adobescripts.co.uk