metalsmith-tinify
A metalsmith plugin to compress images uning the tinify API using a local cache to minimize API calls.
Installation
$ npm i metalsmith-tinify --save
Example
const Metalsmith = require('metalsmith');const tinify = require('metalsmith-tinify'); Metalsmith(__dirname) .source('./src') .destination('./build') .use(tinify({ apiKey: 'yourapikey', // Required: Get your API key from https://tinypng.com/developers })) .build(function(err) { if (err) throw err; });
Options
You can pass options to metalsmith-tinify
with the Javascript API
or CLI.
The options are:
apiKey
required
Tinify API key - you can get your api key from https://tinypng.com/developers
pattern
optional
default: ['**/*.jpg', '**/*.jpeg', '**/*.png']
A multimatch pattern. Only files that match this pattern are tinified. Can be a string or an array of strings.
cacheDir
optional
default: path.join(os.tmpdir(), 'metalsmith-tinify-cache')
All once tinified images are cached. This options specifies the cache directory to use.
Problems?
You can allways switch debugging output on by setting NODE_DEBUG environment variable to metalsmith-tinify
.
See the awesome debug module for more details.
License
ISC