mongoose-crate-imagemagick
A mongoose-crate FileProcessor that applies image transformations with ImageMagick.
Prequisites
A modern version of ImageMagick installed and available on the path. You may also need GhostScript, I did on one computer but not on another. YMMV.
Usage
You can pass images through one or more ImageMagick filters:
const mongoose = const crate = const LocalFS = const ImageMagick = const PostSchema = title: String description: String PostSchema const Post = mongoose
.. then later:
const post = post
Meta data
mongoose-crate-imagemagick
extends the basic meta data added by mongoose-crate
to add some image specific fields. It provides the following for each transformation:
width: 120 height: 103 depth: 8 format: 'PNG' name: 'dragon.png' size: 26887 url: 'http://my_bucket.s3.amazonaws.com/folder/4fbaaa31db8cec0923000019-medium.png'
ImageMagick transformations
Transformations are achieved by invoking the convert command from ImageMagick and passing all the properties of the transform as arguments.
Example in convert command:
convert source.png -crop 120x120 -blur 5x10 output.png
Example in plugin options:
PostSchema
For more information on available transforms, see the ImageMagick website.
Changing the destination format
You can change the destination format by using the special transform property format
with a known file extension like png, jpg, gif, etc:
PostSchema
Supported formats
By default we'll only try to process a few common image types. The supported list defaults to jpgs, pngs, gifs and tiffs.
This list can be overridden by specifying the formats
argument:
PostSchema
The values should match up with convert
's supported formats. To see a list of all formats supported by your ImageMagick install, run:
convert -list format