https://github.com/jakubandrysek/mkdocs-resize-images
✂️ MkDocs plugin to resize images according to the configuration
https://github.com/jakubandrysek/mkdocs-resize-images
images mkdoc mkdocs-material mkdocs-plugin plugin resize-images
Last synced: 9 months ago
JSON representation
✂️ MkDocs plugin to resize images according to the configuration
- Host: GitHub
- URL: https://github.com/jakubandrysek/mkdocs-resize-images
- Owner: JakubAndrysek
- License: mit
- Created: 2023-06-30T12:49:55.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-04T00:19:19.000Z (over 2 years ago)
- Last Synced: 2025-08-17T16:45:18.147Z (10 months ago)
- Topics: images, mkdoc, mkdocs-material, mkdocs-plugin, plugin, resize-images
- Language: Python
- Homepage: https://resize.kubaandrysek.cz/
- Size: 1.16 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MkDocs Resize Images Plugin
This MkDocs plugin finds all folders with a certain name, by default `assets-large`, resizes all images in those folders according to the plugin configuration.
Then saves the resized images in a different folder, by default `assets`.
The plugin also supports caching: if a file has not changed since the last time the plugin ran, it won't be processed again.
## Installation
Install the plugin using pip from [PyPI](https://pypi.org/project/mkdocs-resize-images/):
```bash
pip install mkdocs-resize-images
```
Activate the plugin in `mkdocs.yml`:
```yaml
plugins:
- search
- resize-images
```
Create `.gitignore` file in your project root directory and add the following line to it:
```bash
assets-large # or whatever you have set as source-dir
.resize-hash # if you have enabled caching
```
## Usage
By default, the plugin will look for images in all directories named assets-large, resize them to 800x600 pixels, and then save the resized images in assets directories in the same parent directories as the assets-large directories.
You can configure the plugin in your mkdocs.yml:
```yaml
plugins:
- search
- resize-images:
source-dir: assets-large
target-dir: assets
enable_cache: True
size: [800, 600]
extensions: ['.jpg', '.jpeg', '.png', '.gif', '.svg']
```
`source-dir`: The name of the directories to search for images to resize. Default is `assets-large`.
`target-dir`: The name of the directories to save the resized images in. Default is `assets`.
`size`: The size to resize the images to, specified as [width, height]. Default is `[800, 600]`.
`extensions`: List of image file extensions to consider for resizing. The plugin will look for images with these extensions in both lower and upper case. Default is `['.jpg', '.jpeg', '.png', '.gif', '.svg']`.
`enable_cache`: Whether to enable caching. If enabled, the plugin will check if a file has changed since the last time the plugin ran, and if not, it won't process the file again. Default is `True`.
`debug`: Option to enable debug output. Default is `False`.