Sunday, 15 April 2012

javascript - Proportional Free Transform -



javascript - Proportional Free Transform -

i'd perform proportional transform on image in photoshop.

i'm looking automatically using javascript interface. i'm kinda familiar doing sort of stuff. transform, 1 must utilize photoshop actionscript language via scriptlistening plugin transform function not exposed in dom.

i'm not familiar these variables doing , i'm having lot of problem determining how create transform proportional (i.e. don't alter aspect ratio enlarge/shrink).

anyone else familiar or have ideas?

var idtrnf = charidtotypeid("trnf"); var desc22 = new actiondescriptor(); var idnull = charidtotypeid("null"); var ref12 = new actionreference(); var idlyr = charidtotypeid("lyr "); var idordn = charidtotypeid("ordn"); var idtrgt = charidtotypeid("trgt"); ref12.putenumerated(idlyr, idordn, idtrgt); desc22.putreference(idnull, ref12); var idftcs = charidtotypeid("ftcs"); var idqcst = charidtotypeid("qcst"); var idqcsa = charidtotypeid("qcsa"); desc22.putenumerated(idftcs, idqcst, idqcsa); var idofst = charidtotypeid("ofst"); var desc23 = new actiondescriptor(); var idhrzn = charidtotypeid("hrzn"); var idpxl = charidtotypeid("#pxl"); desc23.putunitdouble(idhrzn, idpxl, 622.000000); var idvrtc = charidtotypeid("vrtc"); var idpxl = charidtotypeid("#pxl"); desc23.putunitdouble(idvrtc, idpxl, -480.500000); var idofst = charidtotypeid("ofst"); desc22.putobject(idofst, idofst, desc23); var idwdth = charidtotypeid("wdth"); var idprc = charidtotypeid("#prc"); desc22.putunitdouble(idwdth, idprc, 150.000000); var idhght = charidtotypeid("hght"); var idprc = charidtotypeid("#prc"); desc22.putunitdouble(idhght, idprc, 150.000000); var idintr = charidtotypeid("intr"); var idintp = charidtotypeid("intp"); var idbcbc = charidtotypeid("bcbc"); desc22.putenumerated(idintr, idintp, idbcbc); executeaction(idtrnf, desc22, dialogmodes.no);

idprc utilize alter percent of transform. i'm not sure idhrzn , idvrtc doing , how can generate right number such transform not alter aspect ratio of iamge.

as pointed out anna forrest in comments there's no need utilize script listener proportional resize specified percent.

#target photoshop main (); function main () { if (app.documents.length < 1) { alert ('no document open resize.'); return; } // create image 50% smaller. var resizepercent = 0.5; // might want else depending on image content... var resamplemethod = resamplemethod.bicubic; // apply resize photoshop's active (selected) document. var doc = app.activedocument; // image size in document units. var resizedwidth = doc.width.value * resizepercent; var resizedheight = doc.height.value * resizepercent; // apply alter image. doc.resizeimage (new unitvalue (resizedwidth, doc.width.type), new unitvalue (resizedheight, doc.height.type), doc.resolution, resamplemethod); }

javascript photoshop photoshop-script

No comments:

Post a Comment