Reply To: label script

#59289

//DESCRIPTION:Label Images with their Eff ppi
try {
app.activeDocument.layers.add({name:”ImageEffPpi”, layerColor: [255,192,0], printable: false});
} catch (_) { }

try {
app.activeDocument.paragraphStyles.add({name:”ImageEffPpi”, justification: Justification.CENTER_ALIGN});
} catch (_) { }

reportLayer = app.activeDocument.layers.item(“ImageEffPpi”);
reportStyle = app.activeDocument.paragraphStyles.item(“ImageEffPpi”);
imageList = app.activeDocument.allGraphics;

for (im=0; im < imageList.length; im++)
{
try {
showScaleFor (imageList[im]);
} catch (_) {}
}

function showScaleFor (anImage)
{
var gb,fr,pg;
gb = anImage.parent.geometricBounds;
pg = anImage.parent;

while (1)
{
if (pg instanceof Character)
pg = pg.parentTextFrames[0];
if (pg instanceof Document || pg instanceof Spread || pg instanceof Page)
break;
pg = pg.parent;
}

fr = pg.textFrames.add(reportLayer, {geometricBounds: gb, textFramePreferences: {verticalJustification: VerticalJustification.CENTER_ALIGN, ignoreWrap:true}});
fr.insertionPoints[0].appliedParagraphStyle = reportStyle;
if (anImage.effectivePpi[0] == anImage.effectivePpi[1])
fr.contents = twoDec(anImage.effectivePpi[0])+” ppi”;
else
fr.contents = twoDec(anImage.effectivePpi[0]) + “/” + twoDec(anImage.effectivePpi[1]) + ” ppi”;
}

function twoDec(x)
{
return Math.round(x*100)/100;
}

This article was last modified on April 16, 2011

Comments (0)

Loading comments...