A configurable way to generate thumbnails and optimize them with guetzli.
Project description
lektor image resize plugin
This plugin automatically generates thumbnails for any images in your Lektor content. The difference between this plugin and the lektor thumbnail filter is that this plugin is converting all images and you don't need to have any references to the images in your templates.
TL;DR: What does this plugin do?
- It will generate
JPEG
images in the sizes you configured of all images in your Lektor content. - It can optionally optimize the images with the guetzli JPEG encoder. (You have to install the guetzli binary by yourself)
Usage
Use this plugin if you want to be able to link to full-size images in your content, but still want thumbnails to be generated for the link itself. For example, you may have an image called waffle.jpg
, and to link to it in the content (not the template), but also show a thumbnail.
You can do that like so:
<a href="waffle.jpg"><img src="waffle-small.jpg" /></a>
Installation
To install the plugin, just add lektor-image-resize
to your plugins from the command line:
lektor plugins add lektor-image-resize
If you want to use the guetzli JPEG encoder for image post-processing, you have to install it manually.
# example
apt install guetzli
If you have trouble, see the plugin installation section of the Lektor documentation.
Then, create a config file called configs/image-resize.ini
and add
a few sections for images. The section names can be whatever you want, the
final images will be called imagename-sectionname.jpg
. For example, this
config file:
[small]
max_width = 256
[medium]
max_width = 800
max_height = 800
[woowee]
max_width = 2000
use_guetzli = True
Will take a file called waffle.jpg
and create the files waffle-small.jpg
,
waffle-medium.jpg
and waffle-woowee.jpg
. All the files will be created, regardless
of whether the original file is smaller, so you can link without worrying
whether a file will exist or not. If the original file is smaller than the width
you have specified, the file will only be copied, and will not be resized.
If you want to run guetzli at the generated output, set use_guetzli
to True
.
The max_width
/max_height
parameters work like for the Lektor
thumbnail command.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lektor-image-resize-0.3.0.tar.gz
.
File metadata
- Download URL: lektor-image-resize-0.3.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 255a05c9a9570cf69535a68f0c6375e5469c79264e785333e4a587f50819c277 |
|
MD5 | cca85670437ee119b3bc0162121de9e4 |
|
BLAKE2b-256 | 97a927119e2bce4401c6aaa721f8520cadf708340033ff8efa431ae1fe03b6dd |
File details
Details for the file lektor_image_resize-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: lektor_image_resize-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9d3b06a33fe48f072d015b4247ed53f6cb3696956bd0c1f3a2a6ab7272fd72b |
|
MD5 | f57dbbdb220b568b461dd852af04a61b |
|
BLAKE2b-256 | 25a18b13f2a36113064bc862c08b96cb01ca1f2e3915cbb79c6a3aea2333da99 |