-
-
Save cameronmcefee/315e2230202716f6d437 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function getDocumentInfo():Object { | |
var originalUnits:Units = photoshop.preferences.rulerUnits; | |
photoshop.preferences.rulerUnits = Units.PIXELS | |
var info:Object = { | |
hasOpenDocuments: photoshop.documents.length > 0, | |
ruler: friendlyUnits(originalUnits) | |
} | |
if(info.hasOpenDocuments) { | |
var doc:Document = photoshop.activeDocument | |
var ref:ActionReference = new ActionReference() | |
ref.putEnumerated(photoshop.charIDToTypeID("Dcmn"), photoshop.charIDToTypeID("Ordn"), photoshop.charIDToTypeID("Trgt")) | |
var desc:ActionDescriptor = photoshop.executeActionGet(ref) | |
var xOffset:Number = (desc.getInteger(photoshop.stringIDToTypeID("rulerOriginH"))/65536)*-1 | |
var yOffset:Number = (desc.getInteger(photoshop.stringIDToTypeID("rulerOriginV"))/65536)*-1 | |
info.resolution = doc.resolution | |
info.isSelection = doc.selection.bounds != null | |
info.existingGuides = getExistingGuides(xOffset, yOffset) | |
if(info.isSelection){ | |
info.offsetX = parseInt(doc.selection.bounds[0]) + xOffset | |
info.offsetY = parseInt(doc.selection.bounds[1]) + yOffset | |
info.width = parseFloat(doc.selection.bounds[2]) - parseFloat(doc.selection.bounds[0]) | |
info.height = parseFloat(doc.selection.bounds[3]) - parseFloat(doc.selection.bounds[1]) | |
} else { | |
info.offsetX = xOffset+0 | |
info.offsetY = yOffset+0 | |
info.width = parseInt(doc.width.toString()) | |
info.height = parseInt(doc.height.toString()) | |
} | |
} | |
photoshop.preferences.rulerUnits = originalUnits | |
return info | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment