Example of working with GraphicsMagick (or ImageMagick) in Node.js
A Node.js example of working with GraphicsMagick (or ImageMagick) to generate a list of images with data loaded from a JSON file (an external API for example).
It also includes a static page that triggers the image generation and then asynchronously loads it with AJAX (with a retryer in case the image takes too long to generate).
Originally created for Carpoolear, a free carpooling app created by STS Rosario, an NGO from Rosario, Argentina.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
You will need to download and install Ghostscript and you have to install GraphicsMagick binaries. Here’s the GraphicsMagick Windows binaries.
Then, install the GraphicsMagick package globally, and afterwards, install the project dependencies:
npm install -g gm
npm install
NOTE: after installing GhostScript you may need to reinstall GraphicsMagick if you already had installed it.
If you get this error:
Command failed: gm convert: Unable to read font (n019003l.pfb) [No such file or directory].
you can try going to your Ghostscript installation folder (i.e., C:\Program Files\gs\gs9.20), and adding this fonts folder.
nodemon npm start
And open the following URL on your browser: http://localhost:3000/
Heroku needs a little tweaking to work with GraphicsMagick, you’ll need to add a buildpack. Click the following link to use GraphicsMagick in Heroku.
If you need to, here’s how to use ImageMagick with gm on Node.js.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details