-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathplacedImageMarker.jsx
More file actions
61 lines (59 loc) · 1.9 KB
/
placedImageMarker.jsx
File metadata and controls
61 lines (59 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Placed Image Marker for Illustrastor
make new layer and add placed image name. If find too low actual resolution, It marks Red name and Bounds.
*/
var tgt = app.activeDocument.placedItems;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
var xmp;
var actPPI = 0;
var threshold = 200; //PPI
var lyr = app.activeDocument.layers.add();
lyr.name = "Images Info";
var tg,pth,tx;
var cr = [];
cr[0] = new CMYKColor; //regular color
cr[0].cyan = 0;
cr[0].magenta = 0;
cr[0].yellow = 0;
cr[0].black = 100;
cr[1] = new CMYKColor; //warning color
cr[1].cyan = 0;
cr[1].magenta = 100;
cr[1].yellow = 100;
cr[1].black = 0;
cr[2] = new CMYKColor; //warning color
cr[2].cyan = 100;
cr[2].magenta = 0;
cr[2].yellow = 0;
cr[2].black = 0;
for (var i=0;i<tgt.length;i++){
xmp = new XMPFile(tgt[i].file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
var obj = xmp.getXMP();
xmp.closeFile();
obj.serialize(XMPConst.SERIALIZE_READ_ONLY_PACKET | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
var pxls = obj.getProperty(XMPConst.NS_EXIF,"PixelXDimension");
actPPI = pxls/tgt[i].width*72;
//add Info
if (tgt[i].parent.typename=="GroupItem") tg = tgt[i].parent.pathItems[0];
else tg = tgt[i];
pth = lyr.pathItems.rectangle(tg.top, tg.left, tg.width, tg.height);
pth.filled = false;
tx = lyr.textFrames.add();
tx.textRange.justification = Justification.CENTER;
tx.textRange.size = 6;
tx.contents = tgt[i].file.displayName;
tx.position = [tgt[i].left + tgt[i].width/2-tx.width/2, tgt[i].top - tgt[i].height/2-tx.height/2];
if(actPPI>0){
if (actPPI<threshold) {
pth.strokeColor = cr[1];
tx.textRange.fillColor = cr[1];
tx.contents = tgt[i].file.displayName+"\nactual PPI : "+actPPI;
}
else pth.strokeColor = cr[0];
}
else {
pth.strokeColor = cr[2];
tx.textRange.fillColor = cr[2];
tx.contents = tgt[i].file.displayName+"\nXMP Metadata not included.";
}
}