Copy link to clipboard
Copied
Hi,
I recently got some InDesign files from various sources with text and images. In these files, images are scaled from 12% to 600%. So, my task is to fix the layout and send it back to the sender and they will resend it to me after editing. Chances are that they will again scale some of the images to their choice.
I tried the Jongware script, "ImageScaleInfo.jsx", but that is only giving me the scale information.
What I want is a type of Warning alert using the OnSave Event Listener that "Image(s) used in the document is scaled below 80% and above 120%.
Basically, I need a checkpoint that can alert me if the image is scaled below 80% or above 120%.
Can anyone help me with this.
Thanks,
Masood
Something like the following should work
#targetengine "save"
app.addEventListener("beforeSave", function(){
for(var i = 0; i < app.documents[0].allGraphics.length; i++)
{
var img = app.documents[0].allGraphics[i]
if((img.absoluteHorizontalScale < 80 || img.absoluteHorizontalScale > 120) || (img.absoluteVerticalScale < 80 || img.absoluteVerticalScale > 120))
{
alert("Image(s) used in the document is scaled below 80% and above 120%.")
break;
}
}
})
-Manan
Copy link to clipboard
Copied
Something like the following should work
#targetengine "save"
app.addEventListener("beforeSave", function(){
for(var i = 0; i < app.documents[0].allGraphics.length; i++)
{
var img = app.documents[0].allGraphics[i]
if((img.absoluteHorizontalScale < 80 || img.absoluteHorizontalScale > 120) || (img.absoluteVerticalScale < 80 || img.absoluteVerticalScale > 120))
{
alert("Image(s) used in the document is scaled below 80% and above 120%.")
break;
}
}
})
-Manan
Copy link to clipboard
Copied
Hi Manan, It worked perfectly. Thanks again for your quick help.
PS: I sent you a message. Please check that and let me know.
Copy link to clipboard
Copied
Hi Manan,
I added some codes to the script to stop saving the file if the condition is true:
#targetengine "save"
app.addEventListener("beforeSave", function(scaledImages){
for(var i = 0; i < app.documents[0].allGraphics.length; i++)
{
var img = app.documents[0].allGraphics[i]
if((img.absoluteHorizontalScale < 80 || img.absoluteHorizontalScale > 120) || (img.absoluteVerticalScale < 80 || img.absoluteVerticalScale > 120))
{
alert("Image(s) used in the document is scaled below 80% and above 120%.")
scaledImages.stopPropagation();
scaledImages.preventDefault();
break;
}
}
})
PS: Can you email me at: masood.designs@gmail.com