Photoshop Script Cutting Method (habit shortcuts friends can use, very convenient)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.