Featured image of post Automate Image Processing for My Blog

Automate Image Processing for My Blog

This is an introduction to my Python Script that automates image processing.

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

1
python main.py

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.

comments powered by Disqus
All contents licensed under CC BY-NC-SA 4.0 本站所有内容基于CC BY-NC-SA 4.0协议发布,转载需要署名
Built with Hugo
Theme Stack designed by Jimmy