200% modified 200 pixels

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

mead
Posts: 20
Joined: Sat Jul 23, 2022 12:28 am

200% modified 200 pixels

Post by mead »

Code: Select all

        var d = new ActionDescriptor();
        d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
        var d1 = new ActionDescriptor();
        d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
        d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 0);
        d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
        d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("px"), 200);
        d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("px"), 200);
        var d2 = new ActionDescriptor();
        var r = new ActionReference();
        r.putIdentifier(stringIDToTypeID("layer"), 3);
        d2.putReference(stringIDToTypeID("from"), r);
        var r1 = new ActionReference();
        r1.putIdentifier(stringIDToTypeID("layer"), 3);
        d2.putReference(stringIDToTypeID("to"), r1);
        d.putObject(stringIDToTypeID("replaceLayer"), stringIDToTypeID("transform"), d2);
        executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
I want to free transform to 200 pixels, but this is beyond the
How to become a 200 pixels
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: 200% modified 200 pixels

Post by Kukurykus »

Code: Select all

with(activeDocument) crop([0, 0, width, height], null, 200, 200)
mead
Posts: 20
Joined: Sat Jul 23, 2022 12:28 am

Re: 200% modified 200 pixels

Post by mead »

I'm sorry, but this is Crop Tool

Is not Free Transform
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: 200% modified 200 pixels

Post by Kukurykus »

You are right:

Code: Select all

function px(v) {return b[v].as('px')}
function wh(v1, v2) {return 200 / (px(v1) - px(v2)) * 100}
with(activeDocument.activeLayer) b = bounds, resize(wh(2, 0), wh(3, 1)