Skip to main content
Thomas 42541987
Known Participant
October 1, 2019
Question

Indesign script – get xmp metadata for broken links

  • October 1, 2019
  • 4 replies
  • 4399 views

Hi All,

often I have to work with indesign documents at different locations and I have to deal with broken links.

My main problem is to get the credit-lines for missing images (usually JPeG-previews from adobe.stock.com) with a script. These are stored in the indd-file, even if the image-file is missing. See Example 2 below.

Is there a way to get this information by java script? Up to now I only could mange to 
get these information for existing files with the code below (Example 1).

 

Can anyone help, please?

Thanks Thomas

 

 

Example 1 – my code to read xmp-info for existing files:

if (ExternalObject.AdobeXMPScript == undefined){
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'); }
//read Photoshop entry:
var xmpFile = new XMPFile (fileRef.fsName, XMPConst.NS_PHOTOSHOP, XMPConst.OPEN_FOR_READ);
var xmp = xmpFile.getXMP();
xmpFile.closeFile()
var myPS_Credit = xmp.getProperty(XMPConst.NS_PHOTOSHOP,"Credit");
 

 

Example 2 – xmp-data for missing image taken from indd-file displayed with "less-command":

<x:xmpmeta xmlns:x=“adobe:ns:meta/“ x:xm

ptk=“Adobe XMP Core 5.6-c148 79.163765, 2019/01/24-18:11:46        „>

 <rdf:RDF xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#“>

  <rdf:Description rdf:about=““

    xmlns:dc=“http://purl.org/dc/elements/1.1/“

    xmlns:tiff=“http://ns.adobe.com/tiff/1.0/“

    xmlns:xmp=“http://ns.adobe.com/xap/1.0/“

    xmlns:xmpMM=“http://ns.adobe.com/xap/1.0/mm/“

    xmlns:xmpRights=“http://ns.adobe.com/xap/1.0/rights/“

    xmlns:pur=“http://prismstandard.org/namespaces/prismusagerights/2.1/“

   dc:format=“image/jpeg“

   tiff:ResolutionUnit=“2“

   tiff:XResolution=“50000/377“

   tiff:YResolution=“50000/377“

   xmp:CreateDate=“2011-03-23“

   xmp:CreatorTool=“Adobe Stock Platform“

   xmp:MetadataDate=“2019-09-12T08:37:23“

   xmp:ModifyDate=“2011-03-23“

   xmpMM:DocumentID=“30962553“

   xmpMM:InstanceID=“Adobe Stock 30962553“

   xmpRights:Marked=“True“>

   <pur:creditLine>

    <rdf:Bag>

     <rdf:li>Mny-Jhee - stock.adobe.com</rdf:li>

    </rdf:Bag>

   </pur:creditLine>

  </rdf:Description>

 </rdf:RDF>

</x:xmpmeta>

    This topic has been closed for replies.

    4 replies

    Kasyan Servetsky
    Legend
    October 2, 2019

    Sorry, but I'm sick and tired of fighting with this lousy new forum software.

    I really don’t understand why Adobe decided to ruin something that worked well for years.

    Who knows what [removed] is this? Why I can’t just post a reply?

    Thomas 42541987
    Known Participant
    October 3, 2019

    Well, I had to reset my password today ...

    I don´t know what´s going on.

     

    Anyway, I´ll do some tests tonight. I found this, possibly it is a question of different namespaces?

     

    NS_DC  The XML namespace for the Dublin Core schema, http://purl.org/dc/elements/1.1
    NS_IPTC_CORE   The XML namespace for the IPTC Core schema.
    NS_RDF    The XML namespace for RDF.
    NS_XML    The XML namespace for XML.
    NS_XMP    The XML namespace for the XMP basic schema.
    NS_XMP_RIGHTS  The XML namespace for the XMP copyright schema.
    NS_XMP_MM    The XML namespace for the XMP digital asset management schema.
    NS_XMP_BJ    The XML namespace for the job management schema.
    NS_XMP_NOTE  The XML namespace for the XMP note schema. An Adobe private namespace; do not create new properties.
    NS_PDF    The XML namespace for the PDF schema.
    NS_PDFX   The XML namespace for the PDFX schema. An Adobe private namespace; do not create new properties.
    NS_PHOTOSHOP   The XML namespace for the Adobe Photoshop custom schema.
    NS_PS_ALBUM  The XML namespace for the Adobe Photoshop Album custom schema.
    NS_EXIF   The XML namespace for Adobe’s EXIF schema.
    NS_EXIF_AUX  The XML namespace for Adobe’s EXIF auxiliary schema.
    NS_TIFF   The XML namespace for Adobe’s TIFF schema.
    NS_PNG    The XML namespace for the PNG schema.
    NS_JPEG   The XML namespace for the JPEG schema.
    NS_SWF    The XML namespace for the Flash small web format schema.
    NS_JPK    The XML namespace for the JPK schema.
    NS_CAMERA_RAW  The XML namespace for the Camera Raw schema.
    NS_DM  The XML namespace for the DM schema.
    NS_ADOBE_STOCK_PHOTO The XML namespace for the Adobe Stock Photos schema.
    NS_ASF    The XML namespace for the Microsoft advanced streaming format schema.

     

     

    Kasyan Servetsky
    Legend
    October 2, 2019

    It seems to me that both should work identically, but it doesn't:

    Kasyan Servetsky
    Legend
    October 2, 2019

    Theoratically, this should work:

    main();
    
    function main() {
    	var doc = app.activeDocument;
    	var link = doc.allGraphics[0].itemLink;
    	var xmp = link.linkXmp;
    	var prop = xmp.getProperty(XMPConst.NS_PHOTOSHOP, "photoshop:Credit");
    	$.writeln((prop == "") ? "FAILED" : prop);
    }


    But in practice it doesn't, though it works, for some reason with, say, XResolution (also with a missing file)

    main();
    
    function main() {
    	var doc = app.activeDocument;
    	var link = doc.allGraphics[0].itemLink;
    	var xmp = link.linkXmp;
    	var prop = xmp.getProperty(XMPConst.NS_TIFF, "tiff:XResolution");	
    	$.writeln((prop == "") ? "FAILED" : prop);
    }

    I don't understand why one works but another doesn't.

    Kasyan Servetsky
    Legend
    October 1, 2019

    I just made a quick test and, yes, it's possible. For example, let's try this code:

    main();
    
    function main() {
    	var doc = app.activeDocument;
    	var link = doc.allGraphics[0].itemLink;
    	var xmp = link.linkXmp;
    	var author = xmp.author;
    	var propCredit = xmp.getProperty(XMPConst.NS_PHOTOSHOP, "Credit");
    }

    It works with a missing link as well.

     

     

    Thomas 42541987
    Known Participant
    October 2, 2019
    @Kasyan_Servetsky
    Thomas 42541987
    Known Participant
    October 2, 2019

    Hi Kasyan,

     

    Unfortunately your code does not work with preview-images downloaded from stock.adobe.com
    The file-information that you request in your code returns an empty string. I think this is because the file-information is empty (see image).

    It is not a problem to access author and credit information for missing files that I created myself, but it seems to be a little tricky with adobe-stock-previews.

    It seems to me, that I need access to the raw-xmp-data (see image 2) ... but I dont know how.

     

    Best, Thomas

     

    BTW: I tested this with Indesign CC 2019/2020 German version