No description, website, or topics provided.
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE.md
README.md
index.js
package.json

README.md

metalsmith-image-resizer

An image resizing plugin for Metalsmith. Not dependent on imagemagick/graphicsmagick!

Installation

npm install metalsmith-image-resizer --save

Dependencies

metalsmith-image-resizer depends on sharp. If you're on Mac OS X, you'll need to install libvips (brew install homebrew/science/vips). If you're on Linux or Windows, no other dependency should be needed.

Usage

API

var Metalsmith = require('metalsmith');
var imageResizer = require('metalsmith-image-resizer');

Metalsmith(__dirname)
	.source(__dirname + "/src")
	.destination(__dirname + "/build")
	.use(imageResizer({
		glob: "img/backgrounds/*",
		width: 1920,
		height: 1080
	}))
	.build(function(err) {
		if (err) throw err;
	})

You can use imageResizer multiple times to resize different globs of images with different options:

Metalsmith(__dirname)
	.source(__dirname + "/src")
	.destination(__dirname + "/build")
	.use(imageResizer({
		glob: "img/backgrounds/*",
		width: 1920,
		height: 1080
	}))
	.use(imageResizer({
		glob: "img/people/*",
		width: 200,
		height: 200
	}))
	.build(function(err) {
		if (err) throw err;
	})

You can also specify an extension that you'd like to convert your photos to:

var Metalsmith = require('metalsmith');
var imageResizer = require('metalsmith-image-resizer');

Metalsmith(__dirname)
	.source(__dirname + "/src")
	.destination(__dirname + "/build")
	.use(imageResizer({
		glob: "img/backgrounds/*",
		width: 1920,
		height: 1080,
		ext: "jpeg"
	}))
	.build(function(err) {
		if (err) throw err;
	})

Credits

Modeled after @tomterl's metalsmith-convert plugin.

This is my (@kenhoff's) first time maintaining an OSS project! Tips, suggestions, issues, and pull requests are all totally appreciated.