Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Zoom in and resize window?

Explorer ,
Jan 15, 2019 Jan 15, 2019

I found an existing script to zoom in (to whatever level you set it at) with the current image/document.

main();

function main(){

// Change the value between the parentheses below

// into your desired percentage:

setZoomLevel(500);

// Leave the code below unchanged

function setZoomLevel(zoom){

if(zoom < 1) zoom =1;

var ref = new ActionReference();

ref.putEnumerated(charIDToTypeID(\"capp\"), charIDToTypeID(\"Ordn\"), charIDToTypeID(\"Trgt\"));

var getScreenResolution = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(stringIDToTypeID('newDocPresetScreenResolution'))/72;

var docResolution = activeDocument.resolution;

activeDocument.resizeImage(undefined, undefined, getScreenResolution/(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, docResolution, ResampleMethod.NONE);};};

I'm wondering if it's possible to modify the script so that it also resizes the window when zooming?

i.e. the equivalent on pressing Command Option = or checking 'Zoom Resizes Windows' in Photoshop's preferences.

TOPICS
Actions and scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 15, 2019 Jan 15, 2019

Zooming changing Photoshop image windows size is a Photoshop preference. You can set it either way in and actions and scripts. And you can use menu items in actions and scripts like the zoom in and zoom out and view actual pixels. Some other menu items also change Photoshop image windows size like fit on screen  and full screens mode.

#target photoshop

//

// test.jsx

//

//

// Generated Tue Jan 15 2019 22:43:36 GMT-0500

//

cTID = function(s) { return app.charIDToTypeID(s); };

sTID = function(s) { return a

...
Translate
Adobe
Community Expert ,
Jan 15, 2019 Jan 15, 2019

Zooming changing Photoshop image windows size is a Photoshop preference. You can set it either way in and actions and scripts. And you can use menu items in actions and scripts like the zoom in and zoom out and view actual pixels. Some other menu items also change Photoshop image windows size like fit on screen  and full screens mode.

#target photoshop

//

// test.jsx

//

//

// Generated Tue Jan 15 2019 22:43:36 GMT-0500

//

cTID = function(s) { return app.charIDToTypeID(s); };

sTID = function(s) { return app.stringIDToTypeID(s); };

//

// Test

//

//

//==================== TestAction ==============

//

function TestAction() {

  // Set

  function step1(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putProperty(cTID('Prpr'), sTID("toolsPreferences"));

    ref1.putEnumerated(cTID('capp'), cTID('Ordn'), cTID('Trgt'));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    desc2.putBoolean(cTID('RWOZ'), false);

    desc1.putObject(cTID('T   '), sTID("toolsPreferences"), desc2);

    executeAction(cTID('setd'), desc1, dialogMode);

  };

  // Set

  function step2(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putProperty(cTID('Prpr'), sTID("toolsPreferences"));

    ref1.putEnumerated(cTID('capp'), cTID('Ordn'), cTID('Trgt'));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    desc2.putBoolean(cTID('RWOZ'), true);

    desc1.putObject(cTID('T   '), sTID("toolsPreferences"), desc2);

    executeAction(cTID('setd'), desc1, dialogMode);

  };

  // Select

  function step3(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('ZmIn'));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select

  function step4(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('ZmIn'));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select

  function step5(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('FtOn'));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select

  function step6(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('ZmOt'));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select

  function step7(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), sTID("screenModeFullScreenWithMenubar"));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select

  function step8(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), sTID("screenModeFullScreen"));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select

  function step9(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), sTID("screenModeStandard"));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  step1();      // Set

  step2();      // Set

  step3();      // Select

  step4();      // Select

  step5();      // Select

  step6();      // Select

  step7();      // Select

  step8();      // Select

  step9();      // Select

};

// EOF

"test.jsx"

// EOF

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 16, 2019 Jan 16, 2019
LATEST

That's very helpful, thanks a lot!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines