Answered
Photoshop Extendscript: get active document weight?
Hello,
Is there a way to get the weight of the active Photoshop CS6 document?
I tried this, but the result is not accurate enough:
thisDoc = app.activeDocument;
// ----------- get the number of pixels
var savedUnitType = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var px = thisDoc.width.value * thisDoc.height.value;
app.preferences.rulerUnits = savedUnitType;
// ----------- get the number of bits/pixel
var bits = getDocBits(thisDoc);
// -----------
alert(px * thisDoc.resolution * bits / 1024 / 1000 / 1000); // Mb
function getDocBits(thisDoc) {
var bits = thisDoc.bitsPerChannel;
if (bits == BitsPerChannelType.EIGHT) {
return 8;
}else if (bits == BitsPerChannelType.ONE) {
return 1;
}else if (bits == BitsPerChannelType.SIXTEEN) {
return 16;
}else if (bits == BitsPerChannelType.THIRTYTWO) {
return 32;
}
}

