Photoshop Script Auto Crop CHANGE LOG Version 6.3 (240304) a. Size panel column 1 align left. Version 6.2.1 (240303) a. Add options subject from path or alpha channel. Version 6.2 (240303) a. Rename function 'processDocCrop' => 'processDoc'. b. Use cropping from Auto Crop Advanced but single margin value and merge to single layer. c. Rename 'cbUseCAFill' => 'cbLessContentAware'. d. Rename 'useCAFill' => 'lessContentAware'. e. Add format BMP. f. Rework UI size width and height to single row. Version 6.1 (231209) a. Function 'mergeLayers' add unlock all layers. b. Progress increment before display not after. c. Return results from cropping function. d. Revise function 'mergeLayers' to handle vector masks correctly. e. Miscellaneous. Version 6.0 (231010) a. Content-aware cropping make compatible with PS v25. b. Add version to error message. Version 5.9 (230822) a. Set 'folderXxxxxLastValid' once selected. b. Add polyfill String prototype 'trim'. c. Miscellaneous. Version 5.8 (221101) a. New function setFolder climb folder hierarchy until one exists. b. Add script variables 'folderXXXXLastValid'. c. Folder property 'fsName' use 'fullName' instead. d. Function getFiles add WEBP to known Photoshop extensions. Version 5.7 (221021) a. Add zoom out after active image done. b. Settings apply function setFolder remove excess return. c. Change default useCAFill to false. d. Select input folder add current location. e. Result when flatten only when process folder. f. Remove path separator when combining pathOutput and subpath. g. Log contents add trailing return. h. Log indexed color. i. Settings apply set list units before value inputs. j. Miscellaneous. Version 5.6 (221015) a. Do not set bottom layer isBackground = false; makes it visible. Next step is merge to a single layer, so no need alter bottom layer. b. Honor process choice last used (or default); do not force active image. c. Function mergeLayers handle vector masks. d. Function mergeLayers incorporate rasterizeLayers as sub-function. e. If result is a single layer, rename it to 'Layer 1'. f. Miscellaneous. Version 5.5 (221013) a. Set suffix when units change. b. Settings save dialog add include input/output folders. c. Settings apply setFolder do not clear value when prop is empty. d. Remove useless function xmpRemoveProfile. Version 5.4 (221010) a. Remove //@target b. Check app name and warn if wrong app for script. c. New handling of files Photoshop can't open. d. Put cropping into function cropImage. e. Don't set output folder to subfolder of input. f. Remember process, subfolders, and input and output folders. g. Do not allow output folder to be input folder. h. Use new select subject function that tries twice instead of inline. j. Remove extra item in drop-down lists. k. New handling for subpath. l. Implement new function openFile. m. Folder objects global and create in btnOK.onClick. n. New handling of output file object creation. o. Script global extension, format. p. Function saveAndClose remove excess catch. q. Update panel 'Settings' to match others. r. Function saveAndClose try all. s. Miscellaneous. Version 5.3 (220803) a. Bring to front and close progress and working at script end. b. Close button false has no effect in Photoshop. c. Correct getFiles() comment. d. Revise function saveAndClose. e. Add script global var extensions. f. JPG save options add matte and scans. a. Use doneMessage instead of var abort. h. Try a second time when select subject fails. i. Log new function addFile to replace logAddFileMessage. j. Replace function notify with alert and confirm. k. Settings current break apart single return statement. l. Settings apply and current try/catch/alert errors. m. Miscellaneous. Version 5.2 (220715) a. Select subject all layers false. b. Use list index instead of text for file format. c. Optimize saving output files. d. Better error handling for select subject. Version 5.1 (220708) a. Updated function settings.setList. b. Settings replace list add empty item so minimum two items. c. Settings list add empty item so minimum two items. d. Settings unlock move to listSettings.onChange. Version 5.0 (220614) a. Allow periods in suffix. b. Equals or not null make strict comparison. Version 4.9 (220523) a. Set doneInfo and doneMessage to empty strings prior to process. b. Update doneMessage, doneInfo, and notify logic. c. Test error 'User cancel' instead of 'User cancelled'. d. getFiles ignore EPS if not raster. e. Remove function testCancel. Not necessary. Version 4.8 (220503) a. DialogModes.NO once processing. Version 4.7 (220426) a. Save PNG set compression 5, interlaced false. b. Add DialogModes.ERROR at begin of script. c. Remove DialogModes.ALL. d. Write log to output folder. Version 4.6 (220331) a. Error app.activeDocument is null when nothing open. Check app.documents.length. Version 4.5 (220329) a. When units are pixels, set UI option resample to original to false. b. Updated function processDocCrop. c. Merge image to single layer before cropping. d. When auto-fill, add margin before cropping and remove after. d. Miscellaneous. Version 4.4 (220328) a. Force integer value when units are pixels. Version 4.3 (220327) a. Updated function loadColorProfiles. b. Set txtUnitsHeight and txtUnitsMargin on settings apply. c. Miscellaneous. Version 4.2 (220318) a. Adjust bounds to reach target crop use Math.ceil instead of Math.floor. Math.floor crops 1 pixel too small, that is added after cropping. b. If units are pixels, resize image to precise pixel size after cropping. c. Default to process active image if an image is open. d. Miscellaneous. Version 4.1 (220307) a. Drop down lists make array third argument instead of in properties object. b. Verbiage 'pixels/inch' correct capitalization and fix singular instance. c. Improved listUnits.onChange. d. Accept decimal comma. e. Do not call changeOption() inside validate functions. f. NEW progress window. g. Process active document, use 'working' window instead of 'progress'. h. When select subject fails, log and save uncropped image. i. Test for no suffix + input/output the same only when processing folder. j. Settings file encoding UTF-8. k. NEW function getFiles. l. Miscellaneous. Version 4.0 (220111) a. Hoist var log. b. Hoist var settings. c. Function setList/listSelection rename control => uiList d. Function validateNumeric rename control => uiEdit Version 3.9 (211212) a. Apply settings implement function getProp. b. Apply settings updated setList function. c. Rename variable listProfile => listProfiles. d. btnOK handler check for profile selected. e. Miscellaneous. Version 3.8 (211203) a. Prevent output to input folder without suffix. Version 3.7 (211130) a. Miscellaneous. Version 3.6 (211127) Implement partial changes versions 3.2 to 3.4 a. Fix error if processing folder and image in it is open. b. Rearrange UI section output. c. Fix NaN error if inputs for size/margin empty so value is "0". d. Width, height, and resolution, zero value not allowed. e. Enhance cropping logic. f. Make input folder a button instead of radio button. Rearrange UI. g. Resample use either Preserve Details 2.0 (up) or bicubic sharper (down). h. Miscellaneous. Version 3.1 (211028) a. Preserve/restore preferences inside process function, using try/finally. b. Miscellaneous. Version 3.0 (211017) a. Updated settings code. b. Miscellaneous. d. listUnitsWidth.onChange set priorIndex always. e. Setting apply, rework if "useCAFill" in o. f. New setList function. g. Lists text default from defaultSettings, otherwise empty strings in defaultSettings. Version 2.9 (210927) a. Update settings load function + other miscellaneous. Version 2.8 (210917) a. Miscellaneous. b. Select output folder, supply current output folder name. Version 2.7 (210916) a. Log save move this.file.close() to finally. b. Settings load/save move file.close() to finally. Version 2.6 (210915) a. UI adjustments (columns). b. Remove support message with email address. Version 2.5 (210819) a. Process folder, create subfolders in output to match input folder structure. b. PNG added 'embedColorProfile = false' which seems to work. We'll see. Version 2.4 (210818) a. Add option include subfolders. b. Remove natural sort from getFiles function. Not needed. c. Update getFiles to include subfolders. d. getFiles, ignore if folder == output folder. e. Panel margins adjust to tighten up for additional option. f. Process folder have only one app.refresh(), after cropping. Version 2.3 (210722) a. Add option use content-aware fill. b. Don't restore background if result doesn't fill cropping area. c. Not necessary to save preference display dialogs. Version 2.2.1 (210711) a. Solution to null userData makes new problem. Some users have MyDocuments on a server. Only use new solution if userData returns "/Volumes/null", rather than always. Rather than 'myDocuments', use value for 'desktop'. Version 2.2 (210623) a. Save settings add replace option. b. Fix typos. c. Fix save settings resets resample resolution value. (.current() was missing resolution: inpResolution.text) Version 2.1.2 (210608) a. Fix settings file error userData is null. Use documents and replace path. Version 2.1.1 (210321) a. Alert and confirm supply all arguments. Version 2.1 (210125) a. getFiles implement natural sort. Version 2.0 (201226) a. New processDoc implements Content-Aware cropping. Version 1.3 (201223) a. Active image alert errors instead of write to log. Version 1.2.2 (201013) a. Miscellaneous. Version 1.2.1 (200906) a. PNG and untagged JPG ensure profile is removed. b. Convert indexed color to 8-bit sRGB. Version 1.2 (200831) a. Remove excess colorProfileNames.indexOf. b. Revise closeWasNotOpen function to preserve unsaved docs. c. Fix error check if image fits crop, loop missing property length. d. Miscellaneous. version 1.1 (200828) a. When testing if image fills crop area, test all layers. b. Work around ExtendScript bug: set bg color changes shape layer fill. c. Add UI verbiage to resolution option As-is. d. Add resolution option resample to original Pixels/Inch.