mongoose-crate-gm
A mongoose-crate FileProcessor that applies image transformations with GraphicsMagick via the gm
module.
Prequisites
A modern version of GraphicsMagic installed and available on the path.
Usage
You can pass images through one or more filters:
const mongoose = const crate = const LocalFS = const GraphicsMagic = const PostSchema = title: String description: String PostSchema const Post = mongoose
.. then later:
const post = post
Meta data
mongoose-crate-gm
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'
Transformations
Transformations are achieved by invoking the convert command and passing all the properties of the transform as arguments.
Example in convert command:
gm convert source.png -crop 120x120 -blur 5x10 output.png
Example in plugin options:
PostSchema
For more information on available transforms, see the GraphicsMagick 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 install, run:
gm convert -list format
Using ImageMagick instead of GraphicsMagic
By default the gm
module uses the GraphicsMagic binary. If you wish to use ImageMagick instead, first install a recent version of ImageMagick on your system and add it to your path, then pass true for the imageMagick
option:
PostSchema