Skip to main content
Inspiring
January 7, 2025
解決済み

Resize a layer

  • January 7, 2025
  • 返信数 3.
  • 1265 ビュー

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.

解決に役立った回答 Stephen Marsh

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.

返信数 3

Stephen Marsh
Community Expert
Community Expert
January 7, 2025

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);
    }
}

 

Ciccillotto作成者
Inspiring
January 8, 2025

I used the convert to smart object method

Stephen Marsh
Community Expert
Community Expert
January 8, 2025
quote

I used the convert to smart object method


By @Ciccillotto


Curious! Obviously performance and workflow aren't an issue.

 

  1. Convert to SO
  2. Edit the SO
  3. Image Size
  4. Close/Save the SO
  5. Optionally convert the SO back to a layer or rasterize
Stephen Marsh
Community Expert
Stephen MarshCommunity Expert解決!
Community Expert
January 7, 2025

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.

c.pfaffenbichler
Community Expert
Community Expert
January 7, 2025

Are you deliberately avoiding ESTK-code? 

Ciccillotto作成者
Inspiring
January 7, 2025

If I can do it in uxp it's better
Alternatively I try with estk.