https://github.com/jonniecache/jekyll-thumb
This Jekyll plugin automatically generates image thumnails using libvips
https://github.com/jonniecache/jekyll-thumb
image-processing jekyll jekyll-plugin liquid ruby thumbnails vips
Last synced: 3 months ago
JSON representation
This Jekyll plugin automatically generates image thumnails using libvips
- Host: GitHub
- URL: https://github.com/jonniecache/jekyll-thumb
- Owner: JonnieCache
- License: mit
- Created: 2018-10-02T14:10:46.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-29T16:30:53.000Z (over 6 years ago)
- Last Synced: 2025-10-03T15:39:52.947Z (3 months ago)
- Topics: image-processing, jekyll, jekyll-plugin, liquid, ruby, thumbnails, vips
- Language: Ruby
- Size: 9.77 KB
- Stars: 4
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# jekyll-thumb
This Jekyll plugin automatically generates image thumnails using the [vips](https://jcupitt.github.io/libvips) library and the accompanying ruby wrapper, [ruby-vips.](https://github.com/jcupitt/ruby-vips)
libvips is like imagemagick but more modern.
The plugin adds a `thumb` Liquid tag that can be used like so:
```html
{% thumb src="/image.png" width="100" %}
```
This will generate the thumbnail and output something like:
## Development Status
This project was made because I needed thumbnails for [my blog](https://cleverna.me) and I didn't want to use imagemagick. I made it in like an hour and it definitely has bugs. OTOH it's 119 lines of code so if you don't like something you can just change it.
## Installation
Add the gem to your Gemfile:
```ruby
gem 'jekyll-thumb'
```
Then bundle:
$ bundle
Or install it yourself with:
$ gem install jekyll-thumb
Finally install vips using your operating system's package manager, eg.
$ brew install vips
## Usage
Use it like this in any Liquid template:
```html
{% thumb src="/image.png" width="100" %}
```
You must specify either a `width` or a `height`, but not both. Whichever dimension you specify, the other will be scaled to a matching ratio.
To use variables for the image or the dimensions, simply leave out the quotes:
```html
{% thumb src=page.cover_image height=page.cover_image_height %}
```
By default this will wrap the resized `img` in a link to the original, with a `target="_blank"` attribute. To supress this, pass a `link=false` option to the `thumb` tag.
## Optipng
If you have `optipng` installed and in your PATH, you can tell the plugin to run it on all generated png images.
Just add:
```
thumb:
optipng: true
```
To your `_config.yml`
Currently the plugin doesn't optimize other image formats, except for stripping color palettes.
## Caching images
Optimizing and resizing can take a while for some images. You can specify a cache folder in your Jekyll config to let jekyll-thumb cache images between runs.
```
thumb:
cache: "/tmp/images"
```
## Contributing
Make an issue, send a pull request, you know the drill.
## Acknowledgements
Project shamelessly ripped off of [netlify/jekyll-srcset](https://github.com/netlify/jekyll-srcset), it's basically a find-and-replace job.
## Copyright
Copyright (c) 2018 Jonathan Davies. See [LICENSE](LICENSE) for details.