Created
March 26, 2018 00:30
-
-
Save actcoment/45b32d6848180d00b0cb79bb3701fa76 to your computer and use it in GitHub Desktop.
photoshop jsx:photoshopで指定のフォルダのjpgを640pxサイズにリサイズして別のフォルダに移す。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//for PhotoshopCS3 | |
preferences.rulerUnits = Units.PIXELS; | |
//サムネイルの最大サイズ max pixels | |
maxpx = 640; | |
//サムネイルを保存するフォルダ名。このスクリプト実行時に聞かれるフォルダの下に作成する。 | |
thumbDir = 'thumbnail'; | |
//特定のフォルダ以下のすべてのJPGを開く | |
var dirObj = new Folder("C:/Users/name/Pictures/iCloud Photos/Shared/ブログ用"); | |
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 > maxpx){ | |
theDoc.resizeImage(maxpx, h*(maxpx/w), 72, ResampleMethod.BICUBICSHARPER); | |
} | |
//保存する | |
var dObj = new Date(); | |
var y = dObj.getFullYear().toString(); | |
var m = dObj.getMonth() + 1; | |
if(m<10)m="0"+m; | |
var d = dObj.getDate(); | |
if(d<10)d="0"+d; | |
var str=y+m+d; | |
var newDir = new Folder("C:/Users/name/Dropbox/EvernoteFolder/blog_img_640/"+str); | |
if(! newDir.exists){ newDir.create();} | |
var newFile = new File(newDir.path +'/'+str+"/"+ theDoc.name); | |
var jpegopt = new JPEGSaveOptions(); | |
jpegopt.quality = 7; //0(low)~12(high); | |
theDoc.saveAs(newFile, jpegopt, true); | |
theDoc.close(SaveOptions.DONOTSAVECHANGES); | |
//いらないファイルなら消す | |
//var file=files[i].remove(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment