From 12bb1db5f73d2c1dc8869bb31d9f7de43d0d6d70 Mon Sep 17 00:00:00 2001
From: Eric Rasmussen <erasmussen2@unl.edu>
Date: Tue, 26 Apr 2011 20:52:39 +0000
Subject: [PATCH] Photoshop jpg compression script and updated README

---
 README                                       |  6 +++-
 map_source/photoshop_jpg_compress_script.jsx | 36 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 map_source/photoshop_jpg_compress_script.jsx

diff --git a/README b/README
index e97fdecf..7e9f82df 100644
--- a/README
+++ b/README
@@ -34,7 +34,11 @@ Editing JPGs
         cd /path/to/workspace/unl_tourmap/www/images/tilesets/unl
     2. Run:
         find . -name *.jpg -type f -exec php ../../../../map_source/process_jpgs.php {} \;
-
+Compressing JPGs
+    (Quality can be adjusted by opening the script file specified below and changing the number by the comment "set quality to suit")
+    1. In Photoshop CS5: File->Scripts->Browse...
+    2. Select /path/to/workspace/unl_tourmap/map_source/photoshop_jpg_compress_script.jsx
+    3. Select /path/to/workspace/unl_tourmap/www/images/tilesets/unl
 
 
 ** Updating Map Features:
diff --git a/map_source/photoshop_jpg_compress_script.jsx b/map_source/photoshop_jpg_compress_script.jsx
new file mode 100644
index 00000000..f591167b
--- /dev/null
+++ b/map_source/photoshop_jpg_compress_script.jsx
@@ -0,0 +1,36 @@
+var imageFolder = Folder.selectDialog("Select the folder with JPGs to process"); 
+if (imageFolder != null)  processFolder(imageFolder);
+
+function processFolder(folder) {
+    var fileList = folder.getFiles()
+     for (var i = 0; i < fileList.length; i++) {
+        var file = fileList[i];
+  if (file instanceof File && file.name.match(/\.jpg$/i)) {
+     			open(file);
+var doc = app.activeDocument;
+var strtRulerUnits = app.preferences.rulerUnits;
+var strtTypeUnits = app.preferences.typeUnits;
+app.preferences.rulerUnits = Units.PIXELS;
+app.preferences.typeUnits = TypeUnits.PIXELS;
+var saveFile = new File(decodeURI(activeDocument.fullName.fsName)); 
+saveFile.remove();
+SaveForWeb(saveFile,25); // set quality to suit
+app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
+app.preferences.rulerUnits = strtRulerUnits;
+app.preferences.typeUnits = strtTypeUnits;      
+		 
+  } else 
+if (file instanceof Folder) {
+       processFolder(file);
+     }
+   }
+}
+function SaveForWeb(saveFile,jpegQuality) {
+var sfwOptions = new ExportOptionsSaveForWeb(); 
+   sfwOptions.format = SaveDocumentType.JPEG; 
+   sfwOptions.includeProfile = false; 
+   sfwOptions.interlaced = 0; 
+   sfwOptions.optimized = true; 
+   sfwOptions.quality = jpegQuality;
+app.activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
+}
\ No newline at end of file
-- 
GitLab