Skip to main content

A configurable way to generate thumbnails and optimize them with guetzli.

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.
  • It try to 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

You have to install the guetzli JPEG encoder.

# 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

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. 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.2.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

lektor_image_resize-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file lektor-image-resize-0.2.0.tar.gz.

File metadata

  • Download URL: lektor-image-resize-0.2.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for lektor-image-resize-0.2.0.tar.gz
Algorithm Hash digest
SHA256 379254ad4b72ec27fde37c04a6175eb75c16ce7da5997a61e163eadc283f3462
MD5 d28e5e07bf687c2df2d6515cdb068434
BLAKE2b-256 3cbed2b7fe16d3458ff770842902d903810d86aeebf88b1ae98cb621803362cf

See more details on using hashes here.

File details

Details for the file lektor_image_resize-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: lektor_image_resize-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for lektor_image_resize-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfbaca4c5d37004f4ccf4b1a4b136d61b5d63228b2279f9043a90699067b48b2
MD5 a92ab0d0223b05060a55e872158919ba
BLAKE2b-256 7f8b9b89ea84dca90b713b2479e2cc4e909654b18b76b03666c7526c764a30e1

See more details on using hashes here.

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