vitor Posted November 30, 2021 Posted November 30, 2021 (edited) Usage Compress PNG, JPEG, and WebP images with TinyPNG via the Universal Action. Alternatively, find images with the tinypng keyword. ⤓ Install on the Alfred Gallery | Source Edited August 9, 2023 by vitor Le Tien, JJJJ and Vero 2 1
vitor Posted December 4, 2021 Author Posted December 4, 2021 How to Report Issues Accurate and thorough information is crucial for a proper diagnosis. At a minimum, your report should include:The debugger output of the failing action.Your installed versions of: the Workflow, Alfred, and macOS. Be precise, don’t say “latest”.More information is always welcome. A short video of the steps with the debugger open may help to identify the problem faster.
Maciej Swoboda Posted January 5, 2022 Posted January 5, 2022 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 Le Tien 1
vitor Posted January 5, 2022 Author Posted January 5, 2022 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.
Maciej Swoboda Posted January 5, 2022 Posted January 5, 2022 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. vitor 1
Vero Posted January 6, 2022 Posted January 6, 2022 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
Le Tien Posted January 18, 2022 Posted January 18, 2022 work great on Macbook m1, tks for your workflow vitor 1
vitor Posted February 6, 2022 Author Posted February 6, 2022 Update. Added a new External Trigger to compress without showing a notification. This is useful if, for example, you have a directory on watch whose files automatically get compressed and don’t want to get notifications for those automated steps. To update, download the latest version (same URL) or wait a few days and it’ll prompt you to on next usage, since it uses OneUpdater.
vitor Posted July 13, 2022 Author Posted July 13, 2022 (edited) Updated to 2022.4. Use Alfred 5 features GUI User Configuration. Remove update conditional. Edited July 13, 2022 by vitor _zen_ 1
absoluut Posted July 20, 2022 Posted July 20, 2022 What's the best way to achieve the directory watch for auto-compression? I've been trying to have Hazel sort files and then trigger an AppleScript, but can't seem to get Alfred to recognize the input file.
vitor Posted July 20, 2022 Author Posted July 20, 2022 42 minutes ago, absoluut said: What's the best way to achieve the directory watch for auto-compression? However is most convenient to you. Personally I use launchd whenever I need to watch a path. Though watching a directory and compressing the contents without moving them first might not be a good idea, because the compression itself will change the file and you might end up with an endless cycle of compression. 48 minutes ago, absoluut said: but can't seem to get Alfred to recognize the input file. You need to be explicit about what this means for me to be able to help. How exactly are you calling Alfred on the file? What exactly happens for you to say it isn’t recognised? What does the debugger say?
vitor Posted October 8, 2022 Author Posted October 8, 2022 Updated to 2022.5. Add configurable keyword.
giovanni Posted December 7, 2022 Posted December 7, 2022 @vitor does this work with images in the clipboard? I often take screenshots and I was looking for a way to paste a reduced-size version in my notes. I don't need to save either the initial or transformed image.
vitor Posted December 8, 2022 Author Posted December 8, 2022 11 hours ago, giovanni said: does this work with images in the clipboard? It does not and isn’t planned. Unsure if it’d work, if the image data representation would take that into account. giovanni 1
Tubby Posted February 8, 2023 Posted February 8, 2023 (edited) Great workflow! Just installed and everything works as instructed. However, I want the original file to be left alone and a compressed copy to be made (in the same folder). How do I do that? Edited February 8, 2023 by EricCartman
vitor Posted February 8, 2023 Author Posted February 8, 2023 1 hour ago, EricCartman said: However, I want the original file to be left alone and a compressed copy to be made (in the same folder). That’s not available inside the workflow because it’s not what most people want and it introduces complexity, such as what exactly to call the compressed version and what to do if an image with that name already exists. The way it works is deliberate to avoid surprises and unexpected behaviour. Because the behaviour is predictable, you can build another workflow that calls this one (it has an External Trigger) and otherwise organises stuff like you want. E.g. Make your new workflow first copy the image to the same location with a new name then run the External Trigger on the duplicate. Tubby 1
hnx Posted December 15, 2023 Posted December 15, 2023 Hi folks, I have a question regarding TinyPNG workflow, when I set up api and ran the workflow, nothing generated, then I took a look at the log, there was an error, says: [07:37:16.682] ERROR: TinyPNG[Run Script] Invalid authorization header. My guess it might due to my incorrect API set up since it is the only thing this workflow asks me to do. Here is an image of how I input api into the Environment Variable field, can you please help me to see if anything needs to change? thank you!
Stephen_C Posted December 16, 2023 Posted December 16, 2023 Welcome to the forum. See this post for guidance on how to report a problem with a workflow—noting particularly that you're much more likely to attract the attention of the workflow's author if you post in the relevant thread for the workflow. Stephen
vitor Posted December 16, 2023 Author Posted December 16, 2023 6 hours ago, Stephen_C said: in the relevant thread for the workflow. It’s the official one in this case (as linked per the blog post). Merged with the correct thread. @hnx Remove the environment variable. The correct way to set the API key is in the Workflow Configuration. Always follow the instructions in the Gallery or the workflow itself. That blog post was written before that type of configuration was possible.
hnx Posted December 16, 2023 Posted December 16, 2023 3 hours ago, vitor said: It’s the official one in this case (as linked per the blog post). Merged with the correct thread. @hnx Remove the environment variable. The correct way to set the API key is in the Workflow Configuration. Always follow the instructions in the Gallery or the workflow itself. That blog post was written before that type of configuration was possible. Thank you, it works now.
spongeblink Posted July 4, 2024 Posted July 4, 2024 Another wonderful workflow, @vitor ! But I have a little complain… It would be great if the download file from TinyPNG has the same ‘Creation Date’ attribute as the original file. Since it's just a compressed version of that file. I modified the line in the Run Script object curl --silent "${compressed_url}" --output "${image}" to curl --silent "${compressed_url}" > "${image}" to achieve that. It would be great if you would consider making this change in the published version of this workflow! It would be even better if the backed up files also have this attribute preserved. But the only solution I come up with is rsync --times --crtimes "${image}" "${backup_dir}" with an updated version of rsync from homebrew.
vitor Posted July 4, 2024 Author Posted July 4, 2024 3 minutes ago, spongeblink said: if the download file from TinyPNG has the same ‘Creation Date’ attribute as the original file. Just tested it, and it does. Before and after: Either way, creation time is a bit of a nebulous concept that you shouldn’t rely too much on. 9 minutes ago, spongeblink said: It would be even better if the backed up files also have this attribute preserved. That’s fair. Will be in the next version. 10 minutes ago, spongeblink said: But the only solution I come up with is You just need -p from cp.
spongeblink Posted July 4, 2024 Posted July 4, 2024 10 minutes ago, vitor said: Just tested it, and it does. My mistake, it already does that. I must have looked for the wrong attribute. 12 minutes ago, vitor said: You just need -p from cp. Sadly -p option from cp does not preserve the ‘Creation Date’ attribute on my machine. I'm using macOS 14.5. And this is the before and after: Can this behavior be confirmed on your end?
vitor Posted July 4, 2024 Author Posted July 4, 2024 Just now, spongeblink said: Can this behavior be confirmed on your end? I did before posting, and again now. It preserves it fine for me on 14.5. spongeblink 1
spongeblink Posted July 4, 2024 Posted July 4, 2024 1 minute ago, vitor said: It preserves it fine for me on 14.5. That's weird. What command did you run? Mine was cp -p the_original_image_file.png target_directory I did it once more just to be sure. And the ‘Creation Date’ attribute wasn't preserved on my end. The new file has a same attribute of ‘Date Created’ as the ‘Modified Date’ attribute of the original file.
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