Skip to main content
Inspiring
September 5, 2018
Question

Relink to new image file by pixel-by-pixel comparison

  • September 5, 2018
  • 2 replies
  • 1648 views

Hi

We have 110 indd docs all over the place on servers-workstations with placed 3150 png/tif qr codes. So around 30 links per file.

Want to relink placed images to new share folder with only pngs, but now new images have different names but same content. File size is not option.

Is it possible via indesign scripting to relink but that indesign search for most similar image in new folder and relink old image automatically? pixel-by-pixel comparison or similar.

tnx

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
September 7, 2018

Can you provide a download link to dropbox or similar (not uploaded to the forum, just in case that changes things), with the same QR code in both formats (say 3 pairs of images to check for consistency in data, zip compressed into one file)? There may be are other ways to check for similarity than just pixel content.

On your later post with filename prefix, is the prefix always the same per folder or batch?

kajzicaAuthor
Inspiring
September 8, 2018
Stephen Marsh
Community Expert
Community Expert
September 8, 2018

Thanks, I was hoping for a metadata solution, but nothing leaped out at me in your sample files…

_____________

I’m guessing that you can’t simply batch rename all of your PNG files from:

13452_TIPTOES_1_1.png

To:

1.png

So then you can just relink to the original filename of 1.tif using the built in InDesign feature to relink to the same filename with a different extension.

_____________

This script does work for your situation, however it is not automated and requires the user to have interaction at key points in each doc and to know a little basic regex/grep:

Community Expert
September 5, 2018

Hi kajzica ,

the comparison part pixel-by-pixel could be done by PhotoShop.
With InDesign I see no way. Accessing PhotoShop from InDesign can be done by BridgeTalk.

Here an example with a snippet that opens an image placed with InDesign in PhotoShop:

( function()

{  

    if( app.documents.length == 0 ){ return };

    if( app.documents[0].allGraphics.length == 0 ){ return };

  

    // Have one placed and linked image in the active document:

    var image = app.documents[0].allGraphics[0];

  

    // Get the file path of the image:

    var imagePath = image.itemLink.filePath;

  

    // Test if the image is available:

    if( !File( imagePath ).exists ){ alert( "Error! Image does not exist!"); return };

  

    // We need the BridgeTalk object to talk to PhotoShop:

    var bt = new BridgeTalk;  

    bt.target = "photoshop";

  

    // A more compact way to write the script code for PhotoShop with triple fencing.

    // PhotoShop will open the image:

  

    var psdScript =

  

    '''

    app.displayDialogs = DialogModes.NO;

    var myPsDoc = app.open(File("''' + imagePath + '''"));

  

    // insert code for comparing this image with another one already open or with an image you open after this.

  

    app.displayDialogs = DialogModes.ALL;

  

    ''';

  

    bt.body = psdScript;

    //Idea: Kasyan Servetsky

    bt.onError = function(errObj)

    {

        alert( "Error: " + errObj.body );

    };

    //Idea: Kasyan Servetsky

    bt.onResult = function(resObj) {};

  

    bt.send( 30 );

  

}() )

How could a comparison of pixels be done with PhotoShop?

1. Load both images as layer to one PhotoShop file.

2. Do layer effect Difference on the top layer.

3. Merge the two layers to the background layer.

4. Exploit the Histogram feature.

You should see only one value that is not zero as first entry in the histogram array.

In effect the background layer is totally black with RGB 0,0,0. With a CMYK image the perfect result would be black with 100 C, 100 M, 100 Y, 100 K.

If not there is a difference in the two original images.

For details regarding PhotoShop scripting see:

Adobe Photoshop Scripting

Photoshop Scripting

EDIT:

And of course Davide Barranca's "Professional PhotoShop Scripting"

https://www.ps-scripting.com/

Regards,
Uwe

Community Expert
September 6, 2018

Here a PhotoShop script sample that works with histogram of individual channels in a CMYK image.

Discussion is in German.

Photoshop CC - Kanäle auf Verwendung prüfen

https://www.hilfdirselbst.ch/gforum/gforum.cgi?post=565690#565690

Regards,
Uwe

kajzicaAuthor
Inspiring
September 6, 2018

will try to find solution and report back, as always do.

in midtime, any script which can relink to new link from excel table? column a old name and path, column b new name and path?

  

OLD LINKNEW LINK
C:\a\old.tifd:\b\new.png