This is a Python script to compress your local images then upload to SMMS, and then retrieve image link from SMMS, and replace into the hexo markdown files of post/page.
It supports to cache image MD5 hash to images.db
with JSON format, to save the API usage.
This works perfertly to hexo and hexo-theme-next.
Clone this repository to hexo
root folder.
- Please go to SMMS, register and login.
- Go to SMMS -> User -> Dashboard -> API Token to get your SMMS API key.
- Go to Tinify -> Developer API, enter your name and email address, then you will receive a mail contains Tinify API key.
- Put your SMMS API key and Tinify API key into that script.
- Modify
hexo_source_dir
to your hexo source folder absolute path. - Modify
next_source_dir
to your hexo theme source folder absolute path. - Run the script with Python.
- python3.x
- tinify
- requests
- hashlib
- json
SMMS: 5GB disk Tinify: 500 images per month
You could use the deploy.sh
to make it easier for deployment.
If you are not using pm2
to manage your hexo
job, please remove pm2 restart hexo.js
from deploy.sh
.