Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//for PhotoshopCS3
preferences.rulerUnits = Units.PIXELS;
//サムネイルの最大サイズ max pixels
maxpx = 640;
thumbDir = 'thumbnail';
var dirObj = new Folder("C:/Users/****/Pictures/ブログ用");
var files_jpg = dirObj.getFiles("*.jpg");
var files_png = dirObj.getFiles("*.png");
var savedirObj = new Folder("C:/Users/****/Pictures/blog_img_640");
var saved_jpg = savedirObj.getFiles("*.jpg");
var addednum=saved_jpg.length;
var files= files_jpg.concat(files_png);
for(var i=0; i<files.length; i++){
var theDoc =[i]);
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;
var d = dObj.getDate();
var str=y+m+d;
var newDir = new Folder("C:/Users/michiro/Dropbox/EvernoteFolder/blog_img_640/"+str);
if(! newDir.exists){ newDir.create();}
var num=i+addednum;
var newFile = new File(newDir.path +'/'+str+"/"+ str+"_"+num);
var jpegopt = new JPEGSaveOptions();
jpegopt.quality = 7; //0(low)~12(high);
theDoc.saveAs(newFile, jpegopt, true);
//var file=files[i].remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment