1. Install GraphicsMagick
On Ubuntu (14.04):
sudo apt-get install graphicsmagick
2. Install the Node library in your project
npm install gm
3. Write a script
Below I show two ways of creating a thumbnail. The first way creates a JPG using various GraphicsMagick functions, I prefer this way because it gives me fine grained control over the thumbnail. The second uses a built in function for thumbnails, which is easy to use but isn’t as flexible.
The main problem with the second method is that there is no automatic way of maintaining the aspect ratio. You’d have to do some math on your own first.
If you have any suggestions for improving the code or have any issues/errors running it, please leave a comment below.