I don't understand, why would PS be unable to convert a percent to pixels? It's a simple conversion if you know the total size of the document and the resolution.
Yes it is an easy conversion but when you create a percent unitValue you set the baseUnit to whatever value is 100%. Photoshop has no way of knowing that the value used to set the baseUnit is the document's width or height.
You can also do something like this to get around the limitation.
Code: Select allvar pixValUV = UnitValue(pctVal.as("in"), "in");// set the value and unitType
pixValUV.baseUnit = UnitValue(1/app.activeDocument.resolution,'in');// set the pixel size in a distanceUnit
var pixVal = pixValUV.as("px");
Or you can work in a distanceUnit like inches and do the math without unitValues when you a percentage. i.e. (5/10)*100
CS2 bug?
Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General
Return to “Photoshop Scripting - General Discussion”
Jump to
- Photoshop Scripting
- ↳ Photoshop Scripting - General Discussion
- ↳ Help Me
- ↳ Automation & Image Workflow
- ↳ Photoshop Scripting: Code Snippets
- ↳ Photoshop Scripting: Reference, Documentation, & Tutorials
- ↳ Photoshop Scripts: Beta Testing
- ↳ xtools
- Photoshop Scripts & Photoshop Scripting Services
- ↳ Photoshop Scripts
- ↳ Photoshop Scripting Services
- Adobe Bridge Scripting
- ↳ Adobe Bridge Scripting: General Discussion
- ↳ Adobe Bridge Scripts
- ↳ Adobe Bridge: Bugs, Anomalies, Documentation Errors
- Flex, Flash, or CS SDK/HTML5 panels
- ↳ Flex, Flash & CS SDK: General Discussion
- ↳ Flex, Flash & CS SDK Scripts
- ↳ Flex, Flash & CS SDK Bugs and Anomalies
- Bugs, Anomalies, Documentation Errors
- ↳ Photoshop Scripting Bugs and Anomalies
- ↳ Photoshop Bugs and Anomalies
- ↳ Photoshop Scripting Bug Repository
- Photoshop Scripting Community Site Management
- ↳ Upload
- ↳ Questions, Suggestions and Feedback