ESTKã®å¦ç¿(2) PhotoshopãJSã§æä½ãã
[話è
] ESTK (ExtendScript Toolkit)ã使ã£ã¦ Photoshopãæä½ãã¦ã¿ããã
ESTK㯠PhotoshopCS2ããæè¼ãããã®ã ããããã§ã¯CS3ã§ä½¿ç¨ããã
[åãã®æ] ããããJavaScriptãæ¸ããã¨ã§ã©ããªããããã¨ãã§ãããã ãï¼
[話è ] ã¾ãã¯ãµã ãã¤ã«ç»åä½æã¹ã¯ãªãããä½ã£ã¦ã¿ãã
//for PhotoshopCS3 preferences.rulerUnits = Units.PIXELS; //ãµã ãã¤ã«ã®æ大ãµã¤ãº max pixels maxpx = 160; //ãµã ãã¤ã«ãä¿åãããã©ã«ãåããã®ã¹ã¯ãªããå®è¡æã«èããããã©ã«ãã®ä¸ã«ä½æããã thumbDir = 'thumbnail'; //ç¹å®ã®ãã©ã«ã以ä¸ã®ãã¹ã¦ã®JPGãéã var dirObj = Folder.selectDialog("ãã©ã«ããé¸æãã"); var files = dirObj.getFiles("*.jpg"); for(var i=0; i<files.length; i++){ //ãã¡ã¤ã«éã var theDoc = app.open(files[i]); theDoc.changeMode(ChangeMode.RGB); //ãªãµã¤ãºãã var w = theDoc.width.value; var h = theDoc.height.value; if(w > h && w > maxpx){ theDoc.resizeImage(maxpx, h*(maxpx/w), 72, ResampleMethod.BICUBICSHARPER); }else if(h >= w && h > maxpx){ theDoc.resizeImage(w*(maxpx/h), maxpx, 72, ResampleMethod.BICUBICSHARPER); } //ä¿åãã var newDir = new Folder(theDoc.path +'/'+ thumbDir); if(! newDir.exists){ newDir.create();} var newFile = new File(theDoc.path +'/'+ thumbDir +'/'+ theDoc.name); var jpegopt = new JPEGSaveOptions(); jpegopt.quality = 7; //0(low)ã12(high); theDoc.saveAs(newFile, jpegopt, true); theDoc.close(SaveOptions.DONOTSAVECHANGES); }
[åãã®æ] ç»åã縮å°ããã ããªãããããJavaScriptæ¸ããªãã¦ããã¢ã¯ã·ã§ã³ï¼ããã㧠ã§ããããã©ãã«JavaScript使ãå¿
è¦ããããã ï¼
[話è ] ããã¯ã ãªãç»åã®ç¸¦å¹ ã¨æ¨ªå¹ ã調ã¹ã¦ã以ä¸ã®3ã¨ããã®ã±ã¼ã¹ã«ãã£ã¦æ¡ä»¶åå²ãã¦ãããã¨ããç¹ãåãªãã¢ã¯ã·ã§ã³ã¨ã¯ã¡ããã
- ç¸¦å¹ ï¼æ¨ªå¹ ã§ãç¸¦å¹ ããµã ãã¤ã«æ大å¤(ããã§ã¯160px)ãã大ãã â ç¸¦å¹ ã160pxã«ãªããã縮å°
- æ¨ªå¹ ï¼ï¼ç¸¦å¹ ã§ãæ¨ªå¹ ããµã ãã¤ã«æ大å¤(ããã§ã¯160px)ãã大ãã â æ¨ªå¹ ã160pxã«ãªããã縮å°
- ãã以å¤ï¼ç¸¦å¹ ãæ¨ªå¹ ããµã ãã¤ã«æ大å¤(ããã§ã¯160px)ããå°ããï¼â 縮å°ããªã
[åãã®æ] ãªãã»ã©ããç»åã®å¤§ãããã§å ´ååãããããã«ãJavaScript使ã£ã¦ãããããã
JPGãã¡ã¤ã«ã ãããéããªãã®ããï¼
[話è ] ããããã©ãã·ã§ããã§éãããã¡ã¤ã«ãªããã¹ã¦éãããã«ã§ãããâ¦â¦ã¹ã¯ãªãããããå¤æ´ããã° GIF ã PNG ãéããããã«ãªããæ£è¦è¡¨ç¾ã®ã¨ããã追å ããã°ãã»ãã®ç»åå½¢å¼ã§ã対å¿ã§ããã
var dirObj = Folder.selectDialog("ãã©ã«ããé¸æãã"); -var files = dirObj.getFiles('*.jpg'); +var files = dirObj.getFiles(function(thefile){ + var regex = /(\.jpg|\.jpeg|\.gif|\.png|\.psd|\.tiff?|\.ai|\.bmp)$/i; + if(regex.test(thefile.name)){ + return true; + }else{ + return false; + } +} +);
ãã ãå®éã«ãã£ã¦ã¿ãã¨ãFireworksã®PNGãã¡ã¤ã«ãéãã¨ãã«ãFireworksãã¼ã¿ãè¦ã¤ããã¾ãããã¨ãããã¤ã¢ãã°ãåºã¦ãã¦ä¸æåæ¢ãããã¹ãã¼ã¹ãã¼æ¼ããªã©ããã°ç¶è¡ããããèªåå¦çãä¸æçã«ã¨ã¾ãã®ã¯æ®å¿µã ããã®ãã¤ã¢ãã°åºç¾ãæå¶ããæ¹æ³ã¯åãããªãã£ãã
ãã¨ãAdobe Illustratorã® aiãã¡ã¤ã«ãèªåã§ãµã ãã¤ã«ç»åã«ã§ãããã ãããã¡ã¤ã«ã«ãã£ã¦ã¯ä¸å¯è§£ãªã¨ããã§ãError 8103: ãã¡ã¤ã«ã¯ã¾ã ä¿åããã¦ãã¾ãããã¨ããã¨ã©ã¼ãåºã¦åæ¢ãã¦ãã¾ããããã解決çãåãããªãã
[åãã®æ] ã©ãããã°ãã®ã¹ã¯ãªãããå®è¡ã§ãããã ã£ãï¼
[話è
] PhotoshopCS3ãªãã3ã¤æ¹æ³ããããä¸ã¤ç®ã¯ä»¥ä¸ã®ESTKãèµ·åãã¦ã
ã¹ã¯ãªãããã³ãã¼ãã¼ã¹ããããã¾ãã¯ãã¡ã¤ã«ãèªã¿è¾¼ãã§ã
åçãã¿ã³ãæ¼ã ã¾ãã¯[F5]ãã¼ãæ¼ãã°å®è¡ã§ããã
äºã¤ç®ã¯ãã¹ã¯ãªããã jsxã¨ããæ¡å¼µåãã¤ãã¦ä¿åããã[ãã¡ã¤ã« - ã¹ã¯ãªãã - åç
§] 㧠jsxãã¡ã¤ã«ãéãã¨å®è¡ãããã
ä¸ã¤ç®ã¯ã'C:\Program Files\Adobe\Adobe Photoshop CS3\ããªã»ãã\ã¹ã¯ãªãã'
ã« jsxãã¡ã¤ã«ï¼ããã§ã¯ pscs3-09.jsx
ï¼ãç½®ãã¦ãPhotoshopãåèµ·åãããããã¨ã[ãã¡ã¤ã« - ã¹ã¯ãªãã] ã«ãã®ã¹ã¯ãªãããåºã¦ããã®ã§é常ã®ã³ãã³ãã®ããã«æ±ããã
PhotoshopCSã§ããã®ã¹ã¯ãªããåãããã¨ãã§ããããCSã§ã¯ ESTKããªãã®ã§ä¸ã¤ç®ã®æ段ã¯ã¨ããªãããäºã¤ç®ãä¸ã¤ç®ã®æ段ãªãOKã ãâ¦â¦ããï¼ PhotoshopCSãªã aiãFireworksPNGããåé¡ãªãåæ¢ããã«å¦çã§ãã¦ãã¾ã£ãããªãã§ã ãï¼
[åãã®æ] CS3ã¯ããããªã¨ã©ã¼ãã²ãã£ã¦ãã¾ãã®ãâ¦â¦ãµã¼ãã
ã¨ããã§ããããã¹ã¯ãªããã£ã¦ã©ãä½ãã®ï¼
[話è
] ESTKã®[ãã«ã - PhotoshopCS3 Library] ãè¦ã¦ã¡ã½ããã¨ããããã£ã調ã¹ãªããä½ã£ããã©ããæä½ãã«ããæãããããã©ãªâ¦ã
以ä¸ã®ãµã¤ããåèã«ããã¦ããã£ãã
ãAdobe Photoshop CS3èªååä½æ¦ã http://www.openspc2.org/book/PhotoshopCS3/
æ£è¦è¡¨ç¾ã¯ãRegExp - Mozilla developer centerããåèã«ããã
https://developer.mozilla.org/ja/Core_JavaScript_1.5_Reference/Global_Objects/RegExp
Adobe Photoshop Cs2 Official Javascript Reference (Visual Quickstart Guides)
- ä½è : IncAdobeSystems
- åºç社/ã¡ã¼ã«ã¼: Adobe Pr
- çºå£²æ¥: 2005-10-28
- ã¡ãã£ã¢: ãã¼ãã¼ããã¯