JS CS3 flag duplicate images with scale and rotation differnce
I've been trying to cut down on the number of images a script I have would produce. The old script would look for links that are being used multiple times and then just version the link which is fine. What I am finding this that although a document may have one image linked 9 time 6 times out of the nine the image is scaled and rotated the same amount and the other 3 times the rotation and scaling also match. In this example the image only needs 2 versions the first as the original and the second with the scale and rotation of the image used 3 time let say.
So to the code:
The following code will work through the doc and create an array of the links as duplicates:
function LinkUsage(myLink) {
var myLinkCounter = 0;
for (var myCounter = 0; myCounter < myDoc.links.length; myCounter++) {
if (myLink.filePath == myDoc.links[myCounter].filePath) {
myLinkCounter++;
}
}
return myLinkCounter
}
var myDoc = app.activeDocument;var myNumLinks = [];
for ( var t = myDoc.links.length-1; t >= 0; t-- ){
if(LinkUsage(myDoc.links)>1){
myNumLinks.push(myDoc.links.id);
}
}
Is there a way to loop through the array and only flag the differnent scale and roatations. What I should get is that out of the multiple link uasage the image is only changed twice out of the 9 times used.
I was trying to loop through the array and then loop through it within the loop to compare the link but this does not work for obvious reasons.
for (var i=0 ; i <myNumLinks.length; i++){
var valLink = myDoc.links.itemByID( myNumLinks);
if(valLink.parent.constructor.name == "Image"){
for (var j=0 ; j<myNumLinks.length; j++){
if(myDoc.links.itemByID( myNumLinks).parent.constructor.name == "Image"){
if(valLink.parent.parent.images[0].rotationAngle != myDoc.links.itemByID( myNumLinks).parent.parent.images[0].rotationAngle){
$.write(myNumLinks+"\n");
}
}
}
}
}
Is what I am trying to do possible and if so any suggestions would be appreciated.
Cheers, John.