ActualSize and FitPage

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Skrippy

ActualSize and FitPage

Post by Skrippy »

Ashamed to ask and probably missing basic knowledge, but I can't find any helpful reference on how to implement using MagnificationType.FITPAGE and MagnificationType.ACTUALSIZE on a document...

Script Listener doesn't seem to give anything, so what I hoped for is something like this:

Code: Select allvar srcDoc = app.activeDocument;
srcDoc.magnification = MagnificationType.FITPAGE;
or
Code: Select allsrcDoc.magnification[MagnificationType.FITPAGE];

Etc. No luck so far...

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

txuku

ActualSize and FitPage

Post by txuku »

Bonjour

You can see HERE

and use Code: Select allvar options = new PresentationOptions;
Skrippy

ActualSize and FitPage

Post by Skrippy »

Merci.

It's a hint I can't get working though...

Stuck with[?]:
Code: Select alloptions.magnification = MagnificationType.FITPAGE;

So I've gone to using actions from a script:
Code: Select allif ( imageX > 952 || imageY > 888 ) {
    doAction("- fit on screen","helper actions");
    }
else
    {
    doAction("- actual pixels","helper actions");
    }
larsen67

ActualSize and FitPage

Post by larsen67 »

Are you wanting to make a presentation or are you just wanting to set the Active Document's view state…?
Skrippy

ActualSize and FitPage

Post by Skrippy »

Just wanting to set the Active Document's view state...
I'm ok with what I have now, but useful to add for others or the future, if you know how?

I'm also wondering if I can "softcode" the dimensions for my "viewport"...?
The (imageX > 952 || imageY > 888) pixels is what I normally have free to view pics in.
Would be nice if it was not hardcoded.
larsen67

ActualSize and FitPage

Post by larsen67 »

Then see this previous thread it covers all the options available to photoshop…

bb/viewtopic.php?f=9&t=4774&p=23930&hilit=fton#p23930
Skrippy

ActualSize and FitPage

Post by Skrippy »

Good hints. Thanks!

I expected these to work, but they give me an error "Numerical value expected"...

Code: Select allrunMenuItem( "ActP" ) ;
// or
runMenuItem( "FtOn" ) ;

function runMenuItem( item ) {
cTID = function(s) { return app.charIDToTypeID(s); };
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( cTID( "Mn  " ), cTID( "MnIt" ), cTID( item ) );
desc.putReference( cTID( "null" ), ref );
executeAction( cTID( "slct" ), desc, DialogModes.NO );
}
Mike Hale

ActualSize and FitPage

Post by Mike Hale »

Two things. Unless you are using an old version of Photoshop you don't need that function. runMenuItem() has been an app method for the last few versions.

But either expects a menuID which is numeric. Try
Code: Select allrunMenuItem( charIDToTypeID("FtOn") );

charIDToTypeID converts a four char string into a number. In this case a number that is the menuID for Fit on Screen.
Skrippy

ActualSize and FitPage

Post by Skrippy »

*Aaaargh* Thx!

I had just found another vintage solution:

Code: Select allchangeView( "FtOn");
// or changeView( "ActP");  etc.

function changeView( ID ){
try{
var id240 = charIDToTypeID( "slct" );
var desc65 = new ActionDescriptor();
var id241 = charIDToTypeID( "null" );
var ref53 = new ActionReference();
var id242 = charIDToTypeID( "Mn  " );
var id243 = charIDToTypeID( "MnIt" );
var id244 = charIDToTypeID( ID );
ref53.putEnumerated( id242, id243, id244 );
desc65.putReference( id241, ref53 );
executeAction( id240, desc65, DialogModes.NO );
}
catch(e){}
}
Skrippy

ActualSize and FitPage

Post by Skrippy »

It's not working for the 3 latter ID's longer than 4 chars. Have these changed too?

Mike Hale wrote:here is a list of ID related to the screen menu.
"FtOn"
"ActP"
"ZmIn"
"ZmOt"
"screenModeFullScreen"
"screenModeStandard"
"screenModeFullScreenWithMenubar"