This Pelican plugin optimizes images (jpg and png).
Project description
Optimize Images is a plugin for Pelican, a static site generator written in Python.
Optimize Images applies lossless compression on JPEG and PNG images, with no effect on image quality. It uses jpegtran and OptiPNG.
Installation
The easiest way to install Optimize Images is through the use of pip. This will also install the required Python dependencies automatically.
pip install minchin.pelican.plugins.optimize_images
It is assumed both jpegtran and OptiPNG are installed on system path.
If you are using Pelican 4.5, it should automatically be activated (through my AutoLoader plugin).
If you are using an earlier version of Pelican or autoloading isn’t working, then in your pelicanconf.py file, add Optimize Images to your list of plugins:
PLUGINS = [
# others...
"minchin.pelican.plugins.optimize_images",
# ...
]
Requirements
Optimize Images depends on (and is really only useful with) Pelican. This can be manually installed with pip:
pip install pelican
It is assumed both jpegtran and OptiPNG are installed on system path. On Windows, installers are available at each respective website. On Ubuntu systems, the two can be installed via apt-get:
apt-get install optipng libjpeg-progs
Configuration and Usage
The plugin will activate and optimize images upon finalized signal of pelican.
If add OPTIMIZE_IMAGES_DEV_MODE = True to your pelicanconf.py, this will disable the plugin, which is useful when developing your site locally.
Known Issues
Image manipulation like this can take some time to run. You may consider only adding this plugin to your publishconf.py (rather than your base pelicanconf.py) or add OPTIMIZE_IMAGES_DEV_MODE = True to your pelicanconf.py, which will then only run this image optimization in preparation for site publication.
An issue, as such, is that there is no formal test suite. Testing is currently limited to my in-use observations. I also run a basic check upon uploaded the package to PyPI that it can be downloaded and loaded into Python.
The package is tested in Python 3.10; compatibility with other version of Python is unknown, but there should be nothing particular keeping it from working with other “modern” versions of Python.
Credits
Original plugin from the Pelican-Plugins repo.
License
The plugin code is assumed to be under the AGPLv3 license (this is the license of the Pelican-Plugins repo).
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 minchin.pelican.plugins.optimize_images-1.2.2.tar.gz
.
File metadata
- Download URL: minchin.pelican.plugins.optimize_images-1.2.2.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3ddbfdc36969c89f362e642de542af96502680cb9dc615547b430aa0b502617 |
|
MD5 | b56412a3b7715ab8f93b45f19bbc5d09 |
|
BLAKE2b-256 | 531516d188fd1914f3e87aa551ccf537bbd0c9ce97769719841bde338eb876af |
File details
Details for the file minchin.pelican.plugins.optimize_images-1.2.2-py3-none-any.whl
.
File metadata
- Download URL: minchin.pelican.plugins.optimize_images-1.2.2-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 424b211f1f624066d481639190e1c38e5202a6f16c33d3f65fba3276852bba62 |
|
MD5 | 4c1aa9557cfe246c163b253d6f8d9257 |
|
BLAKE2b-256 | 562a08a5b06f95db12df29a626354b0d0d6941fa577393f36dad036c3dfa4b43 |