Skip to main content
Inspiring
November 23, 2023
Question

[javascript] Detect if placed image has been scaled (by accident)

  • November 23, 2023
  • 4 replies
  • 809 views

Is there a quick way (with Javascript) to detect if a placed image in InDesign has been scaled (by error or accident) after it has been imported and placed? The image properties diesn't seem to help at this point.

 

Sort of like this, but you know, better:

function has_this_been_accidentally_scaled()
{
	var scaled = active_image.transform.scale()
	if (scaled != 100) return true;// Yes, it's too big/small
	else return false; // No, it's at 100% scale
}

 

This topic has been closed for replies.

4 replies

Legend
November 24, 2023

Links panel also has "Actual PPI", "Effective PPI", "Scale", "Skew" ...

See the flyout menu >> Panel Options ...

Robert at ID-Tasker
Legend
November 23, 2023

What would you like to do next - after you found them?

 

 

Of course you can filter out / hide those that are 100% - and end up with this:

 

 

Of course you can also easily find those, that are deformed - Vertical Scale <> Horizontal Scale.

 

Inspiring
November 24, 2023

What would you like to do next - after you found them?    Well... I've got to tell the images that they've been very, very naughty!

 

Not it's more of a visual inspection. It's really important that some images are the correct size and I don't want to go to print if that occurs. So if I can flag that down first, I'll no what's what.

Robert at ID-Tasker
Legend
November 24, 2023

If you need to do it through scripting - then you'll need to wait for someone else to write you a script - I'm not JS guy. 

 

But if you work on a PC - you could use my tool - free version will let you find all those objects and double-click will get you to the object instantly. 

 

GNDGN
Inspiring
November 23, 2023

This detects all horizontally and/or vertically scaled images:

var graphics = app.activeDocument.allGraphics;
var output = "";
var c = 0;

for(i=0; i<graphics.length; i++) {
	if(graphics[i].horizontalScale != 100 || graphics[i].verticalScale != 100) {
		c++;
		output += "Item: " + graphics[i].itemLink.name + "\nLayer: " + graphics[i].itemLayer.name + "\n\n";
	}
}

alert("Scaled images: " + c + "\n" + output);
____________________Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5
Mike Witherell
Community Expert
Community Expert
November 23, 2023

Why not setup the Preflight panel to watch for this? It already does it.

Mike Witherell