Mastodon Mastodon - Mac quick action - shrink images
 logo
  • Home 
  • Tags 
  • Blog posts 
  1. Home
  2. Blog posts
  3. Mac quick action - shrink images

Mac quick action - shrink images

Posted on February 8, 2022  (Last modified on July 11, 2024) • 1 min read • 157 words
Automation   Desktop   Mac  
Automation   Desktop   Mac  
Share via
Link copied to clipboard

Problem: A list of images, which are big. And one wants to make them smaller, maybe for the web.

Solution: A Mac Automator quick action.

Prerequisites: GNU parallel, ImageMagick (both via homebrew)

You …

  • open Automator
  • create a new quick action
  • add Shell script action
  • paste in the script below
  • make sure arguments are passed via stdin

automator quick action for shrinking images

export PATH=$PATH:/usr/local/bin
export size=1280

# that SHOULD work, but DOES NOT (at least not on my machine)
#parallel -a - convert {1} -resize "${size}x${size}\>" -quality {2} {1.}.${size}px.{2}.{3} ::: 50 80 ::: webp jpg

# that works.
TMP=$(mktemp)
cat > "$TMP"
parallel -r convert {1} -geometry "${size}x${size}\>" -quality {2} {1.}.${size}px.q{2}.{3} :::: "$TMP" ::: 50 80 ::: webp jpg
rm "$TMP"

… or use the easier to understand, non-parallel version:

export PATH=$PATH:/usr/local/bin
export size=1280

while read f ; do
  for ext in webp jpg ; do
    for q in 50 80 ; do
      convert "$f" -resize ${size}x${size} -quality $q "${f%.*}.$size.q$q.$ext"
    done
  done
done
 "Fix" Raindrop addon in Firefox
Location of Mac "Quick Actions" 
In case you want to follow me

Here are some links. The further to the right, the less active.

           
(c) Axel Bock | Powered by Hinode.
Code copied to clipboard