Skip to content

meneer-code/compress-images-mac-automator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compress-images-mac-automator

Quickly Compress Images with Automator (mac)

Instructions:

  1. Fire up Automator (CMD + SPACE, “automator”, ENTER)
  2. File > New, Select “Quick Action”.
  3. In the search field search for “run shell script”, drag the item to the right area.
  4. Setup like this:
    • “Workflow receives current” = “image files”
    • “in” = “finder”
    • “Shell” = “/bin/bash/”
    • “Pass input” = “as arguments”
  5. Paste the following code into the text field below (delete the example code before)
for f in "$@"
do

   echo $f | while IFS= read file
   do
filename=$(basename $file)
ext=$(echo ${filename##*.} | tr "[:upper:]" "[:lower:]")
if [ -f $file ]
then
   if ( [ $ext == "png" ] || [ $ext == "jpg" ] || [ $ext == "jpeg" ] )
then
JSON=curl -i --user api:APIKEY --data-binary @$file https://api.tinypng.com/shrink 2>/dev/null  
URL=${JSON/*url\":\"/}
URL=${URL/\"*/}

curl $URL>${file} 2>/dev/null
fi
fi
done

done

afplay /System/Library/Sounds/Submarine.aiff
  1. Request a API Key from TinyPNG
  2. Click the Link in the Email TinyPNG sends you.
  3. Copy the API Key and replace it in the code fragment where it states APIKEY.
  4. File > Save!
  5. Name the service how you want it to show up in the context menu. (Example: Compress Images).
  6. Done! Right click on an image file in the finder an hit “Compress Images” to let the magic happen!

Alt text

About

Quickly Compress Images with Automator (mac)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published