dotjay 2 Posted February 7, 2018 Share Posted February 7, 2018 For anybody who wants the image file to save as a new file rather than replace the original: Open the "Process image(s)" AppleScript block in the workflow Find this line in the script: save this_image in myPath And insert the following to append the image filename with the target width (e.g. image.png becomes image-300.png when resized to 300px width): -- append target width to file name set oldDelim to AppleScript's text item delimiters set AppleScript's text item delimiters to {"."} set theExt to last text item of myPath set AppleScript's text item delimiters to {"." & theExt} set file_path_list to every text item of myPath set AppleScript's text item delimiters to {"-" & target_width & "." & theExt} set myPath to the file_path_list as string set AppleScript's text item delimiters to oldDelim joeynotjoe and gandalfsaxe 2 Link to post
MrStreeter 0 Posted November 1, 2018 Share Posted November 1, 2018 (edited) I needed a workflow that put the resized images into a sub folder of the originals, so made the following amendments. It can handle multiple file selections within differing directories and place the resize-x folder within the respective directory relative to the original image. Open the "Process image(s)" AppleScript block in the workflow Find the following lines in the downloadable version (Lines 27-28) set myPath to this_file end if And insert the following after it that will create a new directory next to the file being resized in the format of 'resize-{resize-width}' (resize-500, resize-1024 for example) -- Remove the file name from the end of the path string set filePath to characters 1 thru -((offset of "/" in (reverse of items of myPath as string)) + 1) of myPath as text set fileName to name of (info for myPath) -- Create a full path to the folder that we want. set resizeFolderName to ((filePath as text) & "/resize-" & (target_width as text) & "/") as text -- Check for the resize-x folder and create it if not present if folderExists(resizeFolderName) then set outputFolder to resizeFolderName else set createThisFolder to POSIX file filePath as alias tell application "Finder" to make new folder in createThisFolder with properties {name:"resize-" & target_width} set outputFolder to resizeFolderName end if Change the following line (Originally on line 38, with the addition of the above, its now on line 60) save this_image in myPath to save this_image in outputFolder & fileName Add the following function to the end of the file: on folderExists(theFolder) tell application "Finder" try set thisFolder to the POSIX path of theFolder set thisFolder to (POSIX file thisFolder) as text -- set thisFolder to theFolder as alias return true on error err return false end try end tell end folderExists Or, if you want the whole script in one thing, its on a Gist here: https://gist.github.com/danstreeter/23fe01074034832fec09c0b633522559 Edited November 1, 2018 by MrStreeter Correct Gist link Link to post
naymapl 0 Posted November 7, 2019 Share Posted November 7, 2019 Hi - this workflow working perfect with macos 10.14 but stop working on Catalina 10.15. I got always error ( can't get item 1 of {} )- anybody have any idea what is wrong ? Thnaks for any sugestions. Link to post
Davejorg 1 Posted January 10, 2020 Share Posted January 10, 2020 On 11/7/2019 at 11:59 AM, naymapl said: Hi - this workflow working perfect with macos 10.14 but stop working on Catalina 10.15. I got always error ( can't get item 1 of {} )- anybody have any idea what is wrong ? Thnaks for any sugestions. I get the same issue. Any suggestions? Link to post
Acidham 61 Posted January 11, 2020 Author Share Posted January 11, 2020 Seems to be an issue with Image Events under Catalina: https://forums.developer.apple.com/thread/124420 To fix there is a simple solution: https://darjeelingsteve.com/articles/Fixing-"Image-Events"-AppleScripts-Broken-in-macOS-10.15-Catalina.html Quote These problems appear to be caused by Image Events not having Full Disk Access permissions. Fortunately it's an easy fix. First, launch System Preferences and navigate to the Security and Privacy pane. Click the Privacy tab, scroll down the menu on the left, and click on Full Disk Access. Click the + icon in the right hand box, and navigate to System > Library > Core Services. Select Image Events, and click the Open button. IOIO and nicola.efflandrin 2 Link to post
IOIO 3 Posted August 28, 2020 Share Posted August 28, 2020 On 1/11/2020 at 10:25 AM, Acidham said: Seems to be an issue with Image Events under Catalina: https://forums.developer.apple.com/thread/124420 To fix there is a simple solution: https://darjeelingsteve.com/articles/Fixing-"Image-Events"-AppleScripts-Broken-in-macOS-10.15-Catalina.html Great! Thank you very much! Works! 👍 This should be added to the description of the workflow to make it work! Link to post
jen 0 Posted October 20, 2020 Share Posted October 20, 2020 (edited) On 1/11/2020 at 5:25 PM, Acidham said: Seems to be an issue with Image Events under Catalina: https://forums.developer.apple.com/thread/124420 To fix there is a simple solution: https://darjeelingsteve.com/articles/Fixing-"Image-Events"-AppleScripts-Broken-in-macOS-10.15-Catalina.html Can't find the core services folder and image event (System > Library > Core Services) in the latest macOS system (10.15.7), is there any new solution? I rely on this workflow a lot, please help… 😭🙏 Thanks very very very much! Edited October 20, 2020 by jen attach image Link to post
Acidham 61 Posted October 20, 2020 Author Share Posted October 20, 2020 1 hour ago, jen said: Can't find the core services folder and image event (System > Library > Core Services) in the latest macOS system (10.15.7), is there any new solution? I rely on this workflow a lot, please help… 😭🙏 Thanks very very very much! It is there! But why are you looking up for ImageEvents.app in Alfred!? You need to add it to System Preferences → Full Disk Access and click on the + to add it. With this Finder will open Link to post
deanishe 1,405 Posted October 20, 2020 Share Posted October 20, 2020 5 hours ago, jen said: System > Library > Core Services In your screenshot, you’re looking in /Library, not in /System/Library. swiggy 1 Link to post
swiggy 0 Posted October 30, 2020 Share Posted October 30, 2020 Hi does this workflow only work with the same height and width? for example 1080 x 1080? How can change it 1080 x 580 for example? Link to post
Acidham 61 Posted October 30, 2020 Author Share Posted October 30, 2020 2 hours ago, swiggy said: Hi does this workflow only work with the same height and width? for example 1080 x 1080? How can change it 1080 x 580 for example? Your usecase describes cropping but the workflow was build to resize an image. Therefore the answer to your question is no. please also read the usage Description: Usage Select an image in Finder, open Alfred and enter rimage and enter a value for the target width, e.g. rimage 300. The image will be resized to target width by respecting ratio. Works with .jpg and .png. Link to post
swiggy 0 Posted October 30, 2020 Share Posted October 30, 2020 ah, thanks, is there any workflow that u know that will be able to adjust width and height at different values ? Link to post
deanishe 1,405 Posted October 30, 2020 Share Posted October 30, 2020 3 hours ago, swiggy said: Hi does this workflow only work with the same height and width? for example 1080 x 1080? Are you asking if it only works with square images? Link to post
swiggy 0 Posted October 31, 2020 Share Posted October 31, 2020 Im looking to resize other than a square image which this seems to only do that. Link to post
deanishe 1,405 Posted October 31, 2020 Share Posted October 31, 2020 The description says it preserves aspect ratio, so it should work with any image. Link to post
Coffeee 0 Posted December 6, 2020 Share Posted December 6, 2020 hello, have error : "fails to obtain item 1 of {}" picture how can i fix it ? Link to post
Acidham 61 Posted December 7, 2020 Author Share Posted December 7, 2020 On 1/11/2020 at 10:25 AM, Acidham said: Seems to be an issue with Image Events under Catalina: https://forums.developer.apple.com/thread/124420 To fix there is a simple solution: https://darjeelingsteve.com/articles/Fixing-"Image-Events"-AppleScripts-Broken-in-macOS-10.15-Catalina.html Have you tried that? Link to post
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now