how to check the resolution of the linked images ?
Hi all,
Could anyone guide me to write a illustrator script which will check the resolution of the linked file image file in dpi ?
thanks in advance,
Sanat
Hi all,
Could anyone guide me to write a illustrator script which will check the resolution of the linked file image file in dpi ?
thanks in advance,
Sanat
With Sonic's help I was able to get this to work for me. I only tested with .psd .tif & .jpeg
#target illustrator
var docRef = activeDocument;
with (docRef) {
// We are expecting 1 placed item (image) here!!!
var placedWidth = placedItems[0].width;
var placedHeight = placedItems[0].height;
var placedPath = placedItems[0].file;
// The 2 variables below are global
XpixelDimension = 0;
YpixelDimension = 0;
// Call the function
exifDimensions(placedPath);
// Calculate the Height & Width DPI's
var widthDPI = Math.floor(XpixelDimension / (placedWidth / 72));
var heightDPI = Math.floor(YpixelDimension / (placedHeight / 72));
alert('Width DPI is ' + widthDPI + ' Height DPI is ' + heightDPI);
}
function exifDimensions(imageFilePath) {
imageFilePath.open('r');
try {
while (imageFilePath.tell() < imageFilePath.length) {
var line = imageFilePath.readln();
var idxOf = (line.indexOf('<exif:PixelXDimension>') > -1) ? line.indexOf('<exif:PixelXDimension>') : line.indexOf('<exif:PixelYDimension>');
if(idxOf > -1) {
if(line.indexOf('<exif:PixelXDimension>') > -1) XpixelDimension = parseInt(line.substring(line.indexOf(">")+1, line.lastIndexOf("<")));
else YpixelDimension = parseInt(line.substring(line.indexOf(">")+1, line.lastIndexOf("<")));
}
}
}
catch (ex) { alert('Fluff');}
finally { imageFilePath.close(); return [XpixelDimension, YpixelDimension]; }
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.