Skip to main content

A configurable way to generate thumbnails.

Project description

lektor image resize plugin

PyPI version Downloads Linting Python package Upload Python Package

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 using imagemagic.
  • It will generate WEBP images in the same sizes using imagemagic.

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:

<a href="waffle.jpg"><img src="waffle-small.jpg" /></a>
<a href="waffle.jpg"><img src="waffle-small.webp" /></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 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 and $(imagename)-$(sectionname).webp.

Here is a example config file:

[small]
max_width = 512

[medium]
max_width = 900
max_height = 900

[woowee]
max_width = 2000

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.

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

lektor-image-resize-0.5.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

lektor_image_resize-0.5.0-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page