:warning:The old cript is
DEPRECATED
. I switch to FastAPI, and updated the code here. The old code is now in v1.0 Branch.
As you can see, my blog contains cover images. Every time I write an article I need to upload a cover image to the image server. However, the process is complicated and trivial. I need to crop the image to a certain proportion and resize and compress the image to reduce the loading time. Moreover, to put the photographer’s name on the image, I need to use other software. Therefore, I create two python scripts to automate the process.
For more information and code script, please go to my GitHub page.
These scripts are for automating the process of cropping, resizing, adding author’s information, compressing, and uploading an image.
- The compressing service I use tinypng
- The storage for image I user sm.ms
- This script works only for the image download from unsplash.com
Usage
To use correctly, you need to create an api.txt
file that contains only the API key for tinypng. To generate an API key, you can check https://tinypng.com/developers.
main.py
can be easily run in the terminal with the command:
|
|
Once it launched, you can drag and drop any image on it.
automator.py
can be used in Mac’s Automator. By building a server with Automator, I can right click on any image and run the script, or use a shortcut to run the script.