https://github.com/nocduro/hugo-resizer
Script to resize images for the static site generator Hugo
https://github.com/nocduro/hugo-resizer
hugo pillow python3
Last synced: 3 months ago
JSON representation
Script to resize images for the static site generator Hugo
- Host: GitHub
- URL: https://github.com/nocduro/hugo-resizer
- Owner: nocduro
- License: mit
- Created: 2017-05-14T18:29:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-14T18:51:04.000Z (about 8 years ago)
- Last Synced: 2025-01-16T12:01:26.558Z (5 months ago)
- Topics: hugo, pillow, python3
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hugo-resizer
Script to resize images for the static site generator Hugo, using the Python Pillow module.## Overview

Finds images that are used in a [Hugo](https://gohugo.io) static site and creates smaller versions that can more easily be used with html
elements like `srcset`.The script assumes your posts are layed out as follows:
```
└───content
└───post
├───arc-reactor
│ └───images
├───beer-pong
│ └───img
└───flashlight
└───images
```And will put the generated images in their own folders:
```
└───content
└───post
├───arc-reactor
│ └───images
│ ├───1080
│ ├───300
│ └───600
├───beer-pong
│ └───img
│ ├───1080
│ ├───300
│ └───600
└───flashlight
└───images
├───1080
├───300
└───600
```If the `tqdm` progress bar module is installed a progress bar will show the conversion progress. On a test set of 250 images (1.2GB)
the script took around 20 seconds on my i5 4670k with 4 processes. Scales roughly linearly for more CPU cores.## Usage
Script is written in Python3, run from the same directory that the `hugo` command would normally be run for the site:`python hugo_resizer.py`
or
`python3 hugo_resizer.py`
Currently don't have command line options set up, so configuration is done in the script.
The `processes` variable configures how many processes to run in parallel. Set this to how many cores your CPU has.