#target photoshop var inputFolder = Folder ( 'D:/Work/In/'); var outputFolder = Folder( ['D:/Work/out/'] ); var outputFolder1 = Folder( ['D:/Work/out/Large'] ); var outputFolder2 = Folder( ['D:/Work/out/Medium'] ); var outputFolder3 = Folder( ['D:/Work/out/Small'] ); if (a = fileList) { (filetype= '*.eps') } else{ (filetype= '*.tif') } //fileType = ( '*.tif' ); //***You need to understand I'm just a hacker also but above it look to me that a and filelist are undefined so filetype will always be set to '*.esp' if (inputFolder != null && outputFolder != null){ var fileList = inputFolder.getFiles(a); //**** a still looks undefined to me if(fileList.length == 0 ) { alert ("No files found in the folder", "test", "errorIcon") } else { for (var i = 0; i < fileList.length; i++) { if (fileList instanceof File && fileList.hidden == false) { var jpegOptions = new JPEGSaveOptions() jpegOptions.quality = 12; jpegOptions.matte = MatteType.NONE jpegOptions.embedColorProfile = false jpegOptions.formatOptions = FormatOptions.STANDARDBASELINE //*** quality 12 is overkill 10 should be good var docRef = open( fileList ) //*** If you are processing image files and EPS files you may need to test the extension first and have two opens app.preferences.rulerUnits = Units.PERCENT //*** Why percent in you append you stated you wanted pixel sizes in your second append docRef.resizeImage (null, null, 300) //****this changes resolution to 300 DPI why docRef.flatten() //*** not needed for your always using resizeImage below and Photoshop will save a layers document as a flat jpeg file in 8 Bit color mode docRef.resizeImage (40, null, 72) //**** this reduces the documents size to 40% if its original width and maintains its aspect ratio and changes its resoluton setting to 72dpi outputFolder1.create(); //*** this would be better outside the loop and sohold be done onle when the folder does not exists var newName1 = removeExtension(docRef.name); docRef.saveAs(new File(outputFolder1+"/"+newName1+".jpg"), jpegOptions, true, Extension.LOWERCASE) docRef.resizeImage (62.5, null, 72) //*** This reduces the 40% sizes document down in size 62.5% so the image will now be 25% of its original width now I understand your first append //*** you want to save three resized document jpeg images for each (tif and EPS) file opened. outputFolder2.create(); //***Better off outside the loop var newName2 = removeExtension(docRef.name); docRef.saveAs(new File(outputFolder2+"/"+newName2+".jpg"), jpegOptions, true, Extension.LOWERCASE) //*** you could just use newName1 again //app.preferences.rulerUnits = Units.PIXELS //docRef.resizeImage (null, 50, 72) app.preferences.rulerUnits = Units.PIXELS outputFolder3.create(); //*** Again better outside the loop var Wid = docRef.width; var Hig = docRef.height; if (Number(Wid) > 75) { docRef.resizeImage(75,null,); } else if(Number(Hig) >= 50) { docRef.resizeImage(null,50,); } //***I would think some documents may not be resized in here for by this time a small original image may be <= 75 wide and < the 50 high //***from you original append you want the last to be 10% of the original so you should have stayed with percent an work out what additional percent would //***result in reducing the 25% size to a 10% size of the original. That would be an additional 40% for .25 * .4 = .1 which is 10% app.preferences.rulerUnits = Units.PIXELS //*** not need done above in fact you should still be using percent //$.writeln (Wid); //$.writeln (Hig); var newName = removeExtension(docRef.name); docRef.saveAs(new File(outputFolder3+"/"+newName+".jpg"), jpegOptions, true, Extension.LOWERCASE) //*** again you could just have used newName1 docRef.close(SaveOptions.DONOTSAVECHANGES) //var fileObj = File (outputFolder+"/"+newName+".jpg") //var newfile = fileObj.copy (outputFolder3+"/"+newName+".jpg") //$.writeln (fileObj1); //$.writeln (newfile1); //var newcmd = newname.remove() //$.writeln (newcmd); } } alert ("Process completed", "test Conversion") } } /********************************************************************/ function removeExtension(myDoc) { var str = myDoc.split("."); var ext = str[0] return ext; } /********************************************************************/ /********************************************************************/ function convertRGB() { var id11 = charIDToTypeID( "CnvM" ); var desc4 = new ActionDescriptor(); var id12 = charIDToTypeID( "T " ); var id13 = charIDToTypeID( "RGBM" ); desc4.putClass( id12, id13 ); var id14 = charIDToTypeID( "Fltt" ); desc4.putBoolean( id14, false ); executeAction( id11, desc4, DialogModes.NO ); } /********************************************************************/ /********************************************************************/ function removeExt(myDoc) { var str = myDoc.split("."); var ext = str[1] return ext; } /********************************************************************/ /********************************************************************/ function removebit(myDoc) { var str = myDoc.split("."); var ext = str[1] return ext; } /********************************************************************/ |