Photoshop Script Cutting Method (habit shortcuts for friends can use, very convenient) by Wusheying
In fact, the principle of script transduction is the same as installing plugin transduction,But like installing devrocket this kind of plug-in special trouble, also often installed unsuccessful, so directly with the script.
#target photoshopfunction Main () {var doc = App.activedocument;var Psdpath = App.activedocument.path;var outfoldername= " Pngexport "; var twosize=true;var outfolder = new Folder (Psdpath +"/"+outfoldername); if (!outfolder.exists) {Outfolder. Create ();} var lname = Doc.activelayer.name;savelayer (Doc.activelayer, lname, Psdpath, False), function Savelayer (layer, lname, Path, Shouldmerge) {duplayers (); if (shouldmerge = = = Undefined | | shouldmerge = = true) {activedocument.mergevisiblelayers (); } activedocument.trim (Trimtype.transparent,true,true,true,true); var savefile= File (path + "/" +outfoldername+ "/" +lname+ "@2x.png"); Savepng (SaveFile); if (twosize) {var re_width=activedocument.width*0.5; var re_height=activedocument.height*0.5; Activedocument.resizeimage (Re_width,re_height); var savefilesmall= File (path + "/" +outfoldername+ "/" +lname+ ". png"); Savepng (Savefilesmall); } app.activeDocument.close (Saveoptions.donotsavechanges);}} if (documents. length &&!activedocument.activelayer.isbackgroundlayer) {try {main (); } catch (e) {alert (e); }}function duplayers () {var DESCAC = new Actiondescriptor (); var refac1 = new Actionreference (); Refac1.putclass (Charidtotypeid (' dcmn '));d escac.putreference (Charidtotypeid (' null '), REFAC1); Descac.putstring (Charidtotypeid (' Nm '), activeDocument.activeLayer.name); var refac2 = new Actionreference (); Refac2.putenumerated (Charidtotypeid (' Lyr '), Charidtotypeid (' Ordn '), Charidtotypeid (' Trgt ')); Descac.putreference (Charidtotypeid (' Usng '), REFAC2); ExecuteAction (Charidtotypeid (' Mk '), DESCAC, dialogmodes.no);} function Savepng (saveFile) {var pngopts = new Exportoptionssaveforweb; Pngopts.format = Savedocumenttype.png Pngopts.png8 = false; Pngopts.transparency = true; pngopts.interlaced = false; pngopts.quality = 100; Activedocument.exportdocument (The new File (saveFile), exporttype.saveforweb,pngopts); }
Photoshop Script Cutting Method (habit shortcuts friends can use, very convenient)