Posted By

garamond on 10/26/06


Tagged

image photoshop


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jonhenshaw
nicolaspar
visualAesthetic


Image Resizer for Adobe Photoshop CS2


 / Published in: JavaScript
 

  1. /*
  2. resizer.jsx for Adobe Photoshop CS2
  3.  
  4. WARNING: this script changes documents that will be processed.
  5.   so be sure to duplicate documents before script runs.
  6.  
  7. this script resizes images storing in given number of pixel.
  8. smaller images than given number won't be resized.
  9. all images will be changed into RGB color mode.
  10.  
  11. last update: 2006-10-26
  12. */
  13.  
  14. preferences.rulerUnits = Units.PIXELS;
  15.  
  16. cutVal = 960;
  17. fileType = "*.psd";
  18.  
  19. folderObj = Folder.selectDialog("select folder");
  20.  
  21. if(folderObj != null) {
  22. inputFileType = prompt("input file type like '*.psd'", fileType);
  23. if(inputFileType != null) { fileType = inputFileType; }
  24.  
  25. inputCutVal = prompt("input length (pixel)", cutVal);
  26. if(inputCutVal != null) { cutVal = eval(inputCutVal); }
  27.  
  28. fileList = folderObj.getFiles(fileType);
  29.  
  30. for(i = 0; i < fileList.length; i++) {
  31. open(fileList[i]);
  32.  
  33. if(activeDocument.width.value > cutVal || activeDocument.height.value > cutVal) {
  34. if(activeDocument.width.value > activeDocument.height.value) {
  35. activeDocument.resizeImage(
  36. cutVal,
  37. (cutVal / activeDocument.width.value) * activeDocument.height.value,
  38. 72,
  39. ResampleMethod.BICUBICSHARPER
  40. );
  41. } else {
  42. activeDocument.resizeImage(
  43. (cutVal / activeDocument.height.value) * activeDocument.width.value,
  44. cutVal,
  45. 72,
  46. ResampleMethod.BICUBICSHARPER
  47. );
  48. }
  49. }
  50.  
  51. activeDocument.changeMode(ChangeMode.RGB);
  52.  
  53. activeDocument.close(SaveOptions.SAVECHANGES);
  54. }
  55. }

Report this snippet  

You need to login to post a comment.