Skip to main content
Participant
December 5, 2024
Answered

Image Resizing Javascript no longer working in Photoshop 26.1.0

  • December 5, 2024
  • 2 replies
  • 279 views

I have been using the attached script from our website vendor to resize and rename batches of images for our website.  It worked fine until the most recent update of Photoshop.  Now the script creates all blank images and the large image created is huge (175mb or more, even when starting with a small file and is very slow..  Any suggestions on what could be causing this?

This topic has been closed for replies.
Correct answer Stephen Marsh

@Lynne309947120rx2 

 

The large image that should be 700px is creating a 50400 × 50400px image!

The problem is the canvas size step after the trim and image size, it's sizing to 700 inches or whatever the current application ruler units are, not px!

Change this bit from (no units specified):
 
// even out the dimentions to a square Large x Large
doc.resizeCanvas(large, large, AnchorPosition.MIDDLECENTER);

 

To (px specified):

 

// even out the dimentions to a square Large x Large
doc.resizeCanvas(UnitValue(large, "px"), UnitValue(large, "px"), AnchorPosition.MIDDLECENTER);

 

2 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
December 6, 2024

@Lynne309947120rx2 

 

The large image that should be 700px is creating a 50400 × 50400px image!

The problem is the canvas size step after the trim and image size, it's sizing to 700 inches or whatever the current application ruler units are, not px!

Change this bit from (no units specified):
 
// even out the dimentions to a square Large x Large
doc.resizeCanvas(large, large, AnchorPosition.MIDDLECENTER);

 

To (px specified):

 

// even out the dimentions to a square Large x Large
doc.resizeCanvas(UnitValue(large, "px"), UnitValue(large, "px"), AnchorPosition.MIDDLECENTER);

 

Participant
December 6, 2024
Thank you. That fixed the issue.





Lynne-Peterson
Stephen Marsh
Community Expert
Community Expert
December 5, 2024

@Lynne309947120rx2 

 

I'll give it a look, do the files use artboards?

Participant
December 6, 2024
The original files I use the script on are sized to a square at least as
large as 700 px by 700px. Some are larger, but I have only had to change
it to a square image for the last 10+ years I have been using the script.





Lynne-Peterson