Jump to content

Recommended Posts

An Alfred 4 workflow for quickly compressing and resizing images using TinyPNG. Simply select a collection of images or a folder in Finder and activate the workflow.

compressing.gif?raw=true

Installation and Getting Started

  1. Install alfred-tinypng workflow.
  2. All further updates are handled automatically.

You will need to configure the workflow with an API key from TinyPNG. Type tinypng_api to get a link to the pagewhere you can get your API key and to actually set the key when you have gotten it.

tinypng_api.png?raw=true

Usage

Select either a folder, image file or a number of image files in Finder. Afterward, open Alfred and type tinypng. You are presented with the following choices:

tinypng.png?raw=true

Choose an item based on what you want. When selected, the workflow will start compressing/resizing the image(s). After it is done, they will be saved to the same directory and with the same filename as the original image. The original image will be preserved with .bak prepended before the file extension. I.e. if compressing img.jpg, this will now become img.bak.jpg and the compressed image will be saved as img.jpg.

Refer to the TinyPNG documentation for a full explanation of the different resizing options.

Why? Another TinyPNG workflow already exists

  • It doesn't support choosing the files based on what is selected in Finder (which I personally prefer).
  • Only simple compression is supported whereas all TinyPNG compressions and resizing options are supported in this workflow.
  • It seems to be abandoned by the creator (has not been updated since 2015).

Credits

The workflow makes use of the following:

 

Code and more can be viewed on the associated GitHub-repo. If you find this workflow useful, stars are appreciated.

Edited by shmulvad
Add GitHub link
Link to post

I've used the old workflow for years and as you mentioned it hasn't been updated so thought I'd give yours a try. Unfortunately I can't enter my API key. Once I click on Enter/Change API Key it switches to the default search. Can you suggest what could be causing the issue?

Screenshot 2020-08-12 at 11.02.12 am.png

Edited by mixterdee
Adding an image
Link to post
1 minute ago, mixterdee said:

I've used the old workflow for years and as you mentioned it hasn't been updated so thought I'd give yours a try. Unfortunately I can't enter my API key. Once I click on Enter/Change API Key it switches to the default search. Can you suggest what could be causing the issue?

 

Sorry about that. This workflow uses Python 3. Does it work if you do "which python3" in your Terminal and set that as the path for the variable "pythonPath" in the workflow?

Link to post
  • 4 months later...

doesn't work for me. I've tried for at least an hour, ending up installing different versions of python 3 on a new M1 mac mini. I really wish for it to work but it doesn't. First notification is a starting the compression/resizing then another one with Status which is blank and nothing happens. I would appreciate some help

 

Thanks,

Dan

Link to post
On 1/8/2021 at 12:20 AM, DaniTz said:

doesn't work for me. I've tried for at least an hour, ending up installing different versions of python 3 on a new M1 mac mini. I really wish for it to work but it doesn't. First notification is a starting the compression/resizing then another one with Status which is blank and nothing happens. I would appreciate some help

 

Thanks,

Dan

 

Hi Dan. Sorry, but I do not have a M1 machine to test on. I am not sure what causes the issue based on your information, but since at least some of the workflow works based on your information, I think it is not a problem with your Python version and something else is causing it. Can you check the log using the Workflow Debugger and report back on what you see?

Link to post
19 minutes ago, shmulvad said:

I think it is not a problem with your Python version and something else is causing it

 

Out of interest, why have you written the workflow to use a custom Anaconda installation instead of /usr/bin/python3 that's part of macOS?

Edited by deanishe
Link to post
Just now, deanishe said:

 

Out of interest, why have you written the workflow to use a custom Anaconda installation instead of one of the system Pythons that everybody has?

 

It is just the installation I use per default on my personal system if I do not set up a new separate environment for a Python project. I wrote the workflow because I personally had a use case for it and afterward thought I might as well release it publicly now that the workflow existed anyway. When I tried using just "python" from within Alfred to call it, it didn't work on my system (even though "python --version" gives me 3.8.5 in a regular terminal session, even when no conda env is activated). It could be fixed by using the absolute path, so I just did that. I can see it also works (on my system at least) when using "python3" which I agree would have been a better choice as the default.

Link to post
1 hour ago, shmulvad said:

When I tried using just "python" from within Alfred to call it […] even though "python --version" gives me 3.8.5 in a regular terminal session

 

On macOS python is Python 2 (/usr/bin/python), which is what you get in Alfred.

 

You’ve done something to your shell’s PATH to make python point to a Python 3 executable, but Mac apps don’t use your shell environment.


In workflows, I think it’s generally best to hardcode /usr/bin/python or /usr/bin/python3, so you always get a known version regardless of what you or users have done to their environment.

 

Having the python command run Python 3 is a bit dubious, imo, because it contradicts what the OS does.

Link to post

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...