I have dabbled with javascript in the past, but I'm a total newb at scripting Photoshop.
What I need is a script I can use to zoom in at specific intervals and another to zoom out at the same intervals. I plan to use these two scripts in conjunction with Configurator to make a couple buttons for doing the tasks.
Example...
Current zoom is 30%. The Zoom In Script has a an array of zoom levels: 12.5%, 25%, 50%, 100%, 200%, 300%, 400%. The script would detect current zoome level and find the next higher zoom level, 50%, and set the window to that new zoom.
Likewise, Zoom Out would do the same operation selecting the next lower zoom level, 25%.
This is all in an effort to get back some of the functionality moving from CS5 to CS6. I used the zoom menu at the top of the screen a LOT to move to preset zoom levels when drawing on my Wacom Cintiq. This Configurator panel would give most of that functionality back.
Can one of you coding gurus help me with that? Or at least give me a hint as to how to manipulate zoom percentage in Photoshop using javascript?
Thanks!!!
Matt
This should do it...
main();
function main(){
/****************
Use either
zoomIn();
zoomOut();
**************/
if(!documents.length) return;
var zoomLevels=[12.5, 25, 50, 100, 200, 300, 400];
zoomIn();
//zoomOut();
function zoomIn(){
var zoomLevel = getZoomLevel();
for(var z in zoomLevels){
if(Number(zoomLevels[z]) > Number(zoomLevel)){
setZoomLevel(zoomLevels[z]);
break;
}
}
};
function zoomOut(){
var zoomLevel = getZoomLevel();
zoomLevels.reverse();
for(var z in zoomLevels){
if(Number(zoomLevels[z]) < zoomLevel){
setZoomLevel(zoomLevels[z]);
break;
}
}
};
function getZoomLevel(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
return Number(desc.getDouble(stringIDToTypeID('zoom'))*100).toFixed(1);
};
function setZoomLevel( zoom ) {
if(zoom < 1 ) zoom =1;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var getScrRes = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(stringIDToTypeID('newDocPresetScreenResolution'))/72;
var docRes = activeDocument.resolution;
activeDocument.resizeImage( undefined, undefined, getScrRes/(zoom/100), ResampleMethod.NONE );
var desc = new ActionDescriptor();
ref = null;
ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Mn " ), charIDToTypeID( "MnIt" ), charIDToTypeID( 'PrnS' ) );
desc.putReference( charIDToTypeID( "null" ), ref );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );
};
};
Thank you so much for the reply!!!
From what I can gather from Configurator, I can drop a button onto the panel to run a script. I paste the script into the text box. Would I paste this entire script into the text boxes for BOTH buttons and then call zoomIn() or zoomOut() at the bottom of each text box. Or is there some way I should consolodate the code and just call zoomIn() or zoomOut() with the button. I'm not very familiar with Configurator, so I'm not sure how I would put the code in a common location and access it with Configurator buttons.
Thanks again!!!
North America
Europe, Middle East and Africa
Asia Pacific