Copy link to clipboard
Copied
I want to resize a layer to this size 6000x4000
But I didn't find anything in uxp
Does anyone have a piece of code I can use.
Layer bounds is still a thing in UXP, so I'd start there:
https://developer.adobe.com/photoshop/uxp/2022/ps_reference/objects/bounds/
I'll take a look when I have some free time.
Converting the layer to a smart object and editing the content and using image size to a specific px target is also possible for batchPlay UXP, but has more overhead.
Copy link to clipboard
Copied
Are you deliberately avoiding ESTK-code?
Copy link to clipboard
Copied
If I can do it in uxp it's better
Alternatively I try with estk.
Copy link to clipboard
Copied
Layer bounds is still a thing in UXP, so I'd start there:
https://developer.adobe.com/photoshop/uxp/2022/ps_reference/objects/bounds/
I'll take a look when I have some free time.
Converting the layer to a smart object and editing the content and using image size to a specific px target is also possible for batchPlay UXP, but has more overhead.
Copy link to clipboard
Copied
This BatchPlay code was generated with the help of AI (the generated DOM code was useless). Adjust the interpolationType as required:
const app = require('photoshop').app;
const batchPlay = require('photoshop').action.batchPlay;
resizeLayer();
async function resizeLayer() {
const command = {
_obj: "transform",
width: {
_unit: "pixelsUnit",
_value: 6000
},
height: {
_unit: "pixelsUnit",
_value: 4000
},
linked: false,
interfaceIconFrameDimmed: {
_enum: "interpolationType",
_value: "bilinear"
},
};
try {
await batchPlay([command], {});
console.log("Resize completed!");
} catch (err) {
console.error(err);
}
}
Copy link to clipboard
Copied
I used the convert to smart object method
Copy link to clipboard
Copied
I used the convert to smart object method
By @Ciccillotto
Curious! Obviously performance and workflow aren't an issue.
Copy link to clipboard
Copied
Stefano I used the convert to smart object method just because it was easier at the moment, The uxp code you put doesn't work and finding the problem would have cost me time, which I don't have at the moment. Maybe if I free myself up a bit I'll see if I can make it work.
Copy link to clipboard
Copied
Stefano I used the convert to smart object method just because it was easier at the moment, The uxp code you put doesn't work and finding the problem would have cost me time, which I don't have at the moment. Maybe if I free myself up a bit I'll see if I can make it work.
By @Ciccillotto
Ah OK, the .psjs file obviously worked for me (Ps 2024).
Copy link to clipboard
Copied
I hadn't thought about psjs, I'll try it later, if it goes well I'll use this method. Thanks for your help.
Copy link to clipboard
Copied
Stefano I tried with psjs and it works fine
thanks a lot for your help
Copy link to clipboard
Copied
Stefano I tried with psjs and it works fine
thanks a lot for your help
By @Ciccillotto
You're welcome! It always resizes from the default middle-centre. I couldn't work out how to change the resize anchor point.
Copy link to clipboard
Copied
I also had this problem
I solved it using center vertical level and center horizontal
kindly tell me with which AI you created the script above.
Copy link to clipboard
Copied
Yes, post transformation alignment or X/Y translation.
As for AI, I tried "the big 3" - ChatGPT, Claude and CoPilot (surprisingly, Gemini is almost useless for Photoshop scripting).
I tried many iterations of UXP DOM code before giving up and asking it to use BatchPlay instead.
I can't remember which of the 3 provided the final working code, or perhaps it was a combination - feeding the output of one as the input to another.