SizeToCanvas Conditional

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

b0ogdan

SizeToCanvas Conditional

Post by b0ogdan »

Hello,
I am new to photoshop scripting.
I am trying to make my life easier with this script but need some help.
I have thousands of pictures and i need them resized to 4 different jpeg for web.
I found here on PS-Scripts and old SizeToCanvas script which is almost perfect.
The problem is that i have some of the pictures smaller than the canvas i want and this images i don`t want them enlarged.
I just want the bigger ones scaled and centered, the smaller ones just centered.

Also if i can incorporate the save for web inside the script it would be perfect.
Hope someone has an answer.

Thank you.

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

pfaffenbichler

SizeToCanvas Conditional

Post by pfaffenbichler »

I fail to see the four sizes you want in that Script.
Please post the complete code on the Forum directly.

You could include a check for size either in the function »fitImage« itself or before invoking it, an if-clause that compares the document’s width and height to the intended width and height for example.
b0ogdan

SizeToCanvas Conditional

Post by b0ogdan »

Sorry i did not mention the sizes. (53x75px, 130x182px, 285x400px and 489x700px)
But it`s not a problem, i made four copies of the script and using them with Dr Brown Image Processor.
I realize that should be something with IF clause..but don`t know anything about Java Script.
pfaffenbichler

SizeToCanvas Conditional

Post by pfaffenbichler »

Using one Script for all 4 and using a function that takes the dimensions as arguments would probably make more sense.

This is an example of how you could check the width and height against certain pixel values.
Code: Select allvar originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
if (app.activeDocuments.width <= 53 && app.activeDocuments.height <= 75) {…}// replace the dots with the proper code
else {…};// replace the dots with the proper code
preferences.rulerUnits = originalRulerUnits;
b0ogdan

SizeToCanvas Conditional

Post by b0ogdan »

Can you look inside the script and tell me where i should put this?
Thank you.
b0ogdan

SizeToCanvas Conditional

Post by b0ogdan »

Also, anyone has an idea why the script does not work in photoshop on mac os x.
I switched from windows to mac and now i see the script gives me an error.

Error 8800: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- The command “<unknown>” is not currently available.
Line: 16
-> executeAction( id, desc, DialogModes.NO );