Skip to main content
Participant
September 18, 2021
Question

How To Save image width and height with Photoshop Script

  • September 18, 2021
  • 1 reply
  • 333 views

Hello im using Photoshop Scripting to edit layers, and Im trying to figure out how to set the width, and height of the saved image. Im trying to set a width and height of the saved image using new JPEGSaveOptions(); Can anyone assist me with this? My code snippet is below

 

function saveJpeg(name)
{
var doc = app.activeDocument;
var file = new File(doc.path + '/gen/' +name +'.jpg' );
var opts = new JPEGSaveOptions();
opts.quality = 10;
doc.saveAs(file,opts,true, Extension.LOWERCASE);

 

}

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
September 18, 2021

SaveAs save the current active document.  If  you want the Jpeg  to be a particular  size the current document need to be the size you want to save.  If you doe not the degrade the current document in this  process.  Dupe the document Crop the duplicated document to a the centered  Aspect Ration image you want the jpeg to have. Then resample the crop  with Image sized to the size and resolution you the want the Jpeg to have. Save your Jpeg then close the duplicated resized document.

JJMack