Generate JPG and WEBP Images and Thumbnails in predefined sizes.
Project description
lektor image resize plugin
This plugin generates JPG and WEBP Images and Thumbnails in predefined sizes 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 usingimagemagic
. - It will generate
WEBP
images in the same sizes usingimagemagic
.
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.
All images will be converted to webp using Pillow.
You can use the images like that:
<!-- Simple example -->
<a href="waffle.jpg"><img src="waffle-small.jpg" /></a>
<!-- example with srcset -->
<a href="waffle-woowee.webp">
<img src="waffle-small.webp"
srcset="waffle-small.webp 512w, // Viewport bis zu 512
waffle-medium.webp 900w, // Viewport größer als 512
waffle-woowee.webp 1440w" // Viewport größer als 900
/>
</a>
Installation
To install the plugin, add lektor-image-resize
to your plugins from the command line and create a config file:
# add the plugin to lektor
lektor plugins add lektor-image-resize
If you have trouble, see the plugin installation section of the Lektor documentation.
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
and $(imagename)-$(sectionname).webp
.
Here is a example config file:
[small]
max_width = 512
[medium]
max_width = 900
max_height = 900
[woowee]
max_width = 1440
Will take a file called waffle.jpg
and create the files waffle-small.jpg
,
waffle-medium.jpg
and waffle-woowee.jpg
as well as waffle-small.webp
,
waffle-medium.webp
and waffle-woowee.webp
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.
The max_width
/max_height
parameters work like for the Lektor
thumbnail command.
Good to know
There is a filter plugin avaliable at lektor-image-filter available, that can help you to use the image in all configured sizes,
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.6.1.tar.gz
.
File metadata
- Download URL: lektor-image-resize-0.6.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dac3540400597d1342c07b714e7e4c0c4a19d9dc301953a9abd77346f478a3f |
|
MD5 | d4a029600c4753dd35414719f4dbd5cf |
|
BLAKE2b-256 | 767a87a35ba4522be04c1e2075be5a421fd0e5aa764c8c668a590998b78ff84f |
File details
Details for the file lektor_image_resize-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: lektor_image_resize-0.6.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea041b0fff597c2af2b285f7c7268f23c1bc9ddbdc10c2c67563df193c906bc8 |
|
MD5 | 8caf8dba7e218d16566569334dcc19c6 |
|
BLAKE2b-256 | 990f83bb83233a4399442029ca74ec8621744e20ba26eb43b1b878b3d32badac |