Ps Image Resize

Hello, there I am trying to convert my old jsx script to UXP, from the ump documentation resizeImage

I can’t seem to make this work, any help is appreciate it thanks;

const app = window.require("photoshop").app;

  const inputSize = 1200;
  const doc = app.activeDocument;
  if(doc.width >= activeDoc.height){
  await doc.resizeImage(inputSize, null,360);
  } else {
  await doc.resizeImage(null, inputSize,360);

You need to do two things:

  1. await only works inside of an asynchronous function, so you’re going to need to wrap that code up in one.

  2. within UXP anything that changes the document state needs to also be wrapped in an executeAsModal function

This page from the documentation has a simple example demonstrating both:
Execute As Modal


Thanks. a lot, I made it work for now using batchPlay, still navigating how all this works, one thing I noticed the difference in speed between my old jsx and uxp, uxp excute faster. I need study more about all this :slight_smile:

1 Like

Glad you got it working!
I think batchPlay is more widely used by the community than the API at the moment mainly because the API is not complete yet. At least in my personal experience, it’s much quicker to grab some code from Alchemist and wrap it up in a nice reusable function than to go through the API documentation.

1 Like