Jump to content

TinyPNG — Compress images via TinyPNG


vitor

Recommended Posts

Use the File Action, File Filter, or External Trigger to compress PNG, JPEG, and WebP images via TinyPNG.


mlX713P.png


Before using the Workflow, request an API key and add it to the api_key Workflow Environment Variable.


backup_originals takes a directory path to save the unmodified images. Use ~ to reference your home directory. Leave it empty to not save backups.

 

Download | Source

Link to comment
  • 1 month later...

When I try to run the workflow by external trigger I get "Input file is empty" error, but the file is present in the Desktop folder. Can you help? I am a newbie to AppleScript. Thanks!

 

maciek@Tiger-MS ~ % cd ~/Desktop 
maciek@Tiger-MS Desktop % ls
panda.png
maciek@Tiger-MS Desktop % /usr/bin/osascript -e 'tell application id "com.runningwithcrayons.Alfred"
    run trigger ¬
        "compress" in workflow ¬
        "com.alfredapp.tinypng" with argument ¬
        (POSIX path of (path to desktop folder)) & "tinypng panda.png"
end tell'

 

The result: https://monosnap.com/file/xb7M5FnArE4V25jSmBzEvqPFa2a32M

Link to comment

Welcome @Maciej Swoboda,

 

3 minutes ago, Maciej Swoboda said:

but the file is present in the Desktop folder.

 

Are you sure? Because that message comes from the TinyPNG API, not the Workflow, and is exactly what happens when you give it a path which doesn’t exist. The file needs to be a PNG named exactly tinypng panda.png


It also might help if you explain why you are using the External Trigger. That’s for advanced usage.

Link to comment
Quote

The file needs to be a PNG named exactly tinypng panda.png

 

Oh, I got caught by that! I thought that the "tinypng" in not part of the filename, but the command to run the script "tinypng" on the "panda.png" file.

 

Thanks a lot. It works now and I am a bit ashamed.

 

Quote

It also might help if you explain why you are using the External Trigger. That’s for advanced usage.

 

I am trying to use the workflow as part of my Hazel rule set.

Link to comment
10 hours ago, Maciej Swoboda said:

Oh, I got caught by that! I thought that the "tinypng" in not part of the filename, but the command to run the script "tinypng" on the "panda.png" file.

 

That's a very valid point though - I'll keep this in mind for future blog posts and ensure this kind of example doesn't cause confusion :)

Link to comment
  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...