Acidham Posted December 15, 2015 Share Posted December 15, 2015 Resize an image, selected in Finder, to a target width by respecting image ratio. 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. http://t.cn/R42PAI2 xilopaint and nicola.efflandrin 1 1 Link to comment
xilopaint Posted December 15, 2015 Share Posted December 15, 2015 Very handy workflow. Thank you! Link to comment
ilium007 Posted June 20, 2016 Share Posted June 20, 2016 I needed a workflow to handle multiple images so I modified this one to do just that. Hope you don't mind. My code below: on alfred_script(target_width) set theCount to 0 set currSelection to {} tell application "Finder" set theSelection to selection end tell repeat with this_file in theSelection -- try to get a jpg or png try tell application "Finder" set myPath to POSIX path of (this_file as text) end tell tell application "Image Events" -- open the image file set this_image to open myPath -- get dimensions of the image copy dimensions of this_image to {W, H} -- calculate scale factor with given width and scale the image set scale_factor to target_width / W scale this_image by factor scale_factor save this_image in myPath close this_image -- get new image width and height for output set new_W to round (W * scale_factor) rounding as taught in school set new_H to round (H * scale_factor) rounding as taught in school set new_size to new_W & " x " & new_H end tell -- set the_return to (W & " x " & H & " → " & new_size) as text -- return the_return set theCount to theCount + 1 on error errStr number errorNumber return "No image file found!" end try end repeat return ("Processed " & theCount & " images") as text end alfred_script Link to comment
Acidham Posted June 20, 2016 Author Share Posted June 20, 2016 Great thx! I will add it to the next release! Link to comment
chanoh Posted July 23, 2016 Share Posted July 23, 2016 Is it compatible with ver. 3? Where is the destination folder after resizing if it is? Link to comment
Acidham Posted July 23, 2016 Author Share Posted July 23, 2016 Yes it works with very 3. The original images will be overwritten with the resized version. Link to comment
chanoh Posted July 25, 2016 Share Posted July 25, 2016 Yes it works with very 3. The original images will be overwritten with the resized version. I'm trying to use this workflow, but it doesn't make any output. Could you let me know how to figure out the problem? My environment is El Capitan 10.11.5 and Alfred 3.0.3. Link to comment
Acidham Posted July 25, 2016 Author Share Posted July 25, 2016 I am running the same combo but without any issues. Did you debug workflow execution with Alfred? Link to comment
Richard61 Posted September 3, 2016 Share Posted September 3, 2016 Great workflow! Thanks for the work. Link to comment
ixium Posted February 28, 2017 Share Posted February 28, 2017 Use this workflow frequently but has one problem, when I batch them it gets stuck sometimes and says "No Image found" then I have to open image manually and resize it before I am able to continue, keeps happening, like its getting stuck somewhere, would love to figure this out as its such a insanely helpful thing to have! Link to comment
Acidham Posted February 28, 2017 Author Share Posted February 28, 2017 (edited) Can you tell me but more when it fails? - How many items in batch? - any specific Filename pattern when it breaks ? - any specific image format? can you provide me with a zip containing batch items? Edited February 28, 2017 by Acidham Link to comment
ixium Posted March 1, 2017 Share Posted March 1, 2017 It doesnt seem to matter, I tried big batches, small batches it eventually fails. Once I open Preview and do a manual image resize it seems to reset, then I can do a few more and it happens again. The files are all .jpg, with a naming structure from the camera. I will try some other files and see if it has anything to do with naming and let you know Link to comment
Acidham Posted March 6, 2017 Author Share Posted March 6, 2017 I was able to fix a bug where last file in the list was not processed due to a newline added by Alfred. In addition I added a file action which allows to choose files within Alfred and process with Resize Images. Version 1.1 is available on packal.org. @ixium please test the new version an let me know if your issue is fixed. Link to comment
ixium Posted March 6, 2017 Share Posted March 6, 2017 thank you so much, will test now! Link to comment
ixium Posted March 6, 2017 Share Posted March 6, 2017 just kicking back "Processed 0 Images" now, even when trying to do just one image Link to comment
Acidham Posted March 6, 2017 Author Share Posted March 6, 2017 did you trigger rimage with Finder selection or from Alfred ? Link to comment
ixium Posted March 6, 2017 Share Posted March 6, 2017 "rimage 1800" in alfred, will try with finder now Link to comment
ixium Posted March 6, 2017 Share Posted March 6, 2017 ok that worked flawlessly with finder select, but it also didnt tell me it did anything (no pop up) thats no problem with me as long as it works! Link to comment
Acidham Posted March 6, 2017 Author Share Posted March 6, 2017 Ok just updated to 1.2, please install new version from packal.org Note: There are two ways on how to trigger Resize Image: 1. Select one or more files in Finder, open Alfred and type rimage plus target width 2. Search png or jpg via Alfred and use File Action Resize Image Link to comment
ixium Posted March 6, 2017 Share Posted March 6, 2017 trying new version now, thank you for your help! Link to comment
ixium Posted March 6, 2017 Share Posted March 6, 2017 Ok both ways work flawlessly now! All images resized with both ways and both kicked out the correct "resized 45 images" Great job! This is such a useful tool for a web designer! Link to comment
mrx3k1 Posted March 12, 2017 Share Posted March 12, 2017 Thanks for this awesome tool! Really great work! Do you have an advice how to get it working in ForkLift3? I guess I have to "collect" the paths of the images from there... Link to comment
Acidham Posted March 13, 2017 Author Share Posted March 13, 2017 I am not using FL3 but get selection only works in Finder. You have to use Alfred for collecting images and use file action command. Does FL3 support any scripts or action command from AppleScript or Bash? If yes I could take a look on how to enhance my WF. Link to comment
mrx3k1 Posted March 15, 2017 Share Posted March 15, 2017 Sorry for the delay. Sadly FL3 doesn't provide such an interface, I guess. But it's not the biggest deal in the world. Link to comment
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