I've installed the npm gm as the tutorial says.
https://github.com/aheckmann/gm
I installed gm with homebrew and after that I installed the npm.
Now when I'm trying to use this:
var fs = require('fs')
, gm = require('./gm');
This is my Code to append images:
gm(dir+"img/slots/test1.png").append(dir+"test2.png").write(dir+'appended.png', function (err) {
if (!err) console.log('done');
});
It tells me Cannot find module './gm'
Edit: it works now seems like I had the wrong syntax
gm(dir+'test1.png')
.append(dir+'test2.png')
.autoOrient()
.write(dir+'newIMAGE.png', function (err) {
if (err) return handle(err);
console.log('Created an image from a Buffer!');
});
Was the way to go Thanks for all answers Anyone has an idea?
I'll try to take a crack at this. For Mac users. I bet Windows might be same solution.
I installed GM by downloading and decompressing and making the source. Install worked and confirmed in terminal
gm version
.require('gm')
didn't work.I then installed GM via NPM and tried globally (
npm install gm -g
). I see it installed (npm install -d
) but stillrequire('gm')
doesn't work.I then went to local directory where the script is located in terminal and NPM installed there.
npm install gm
andrequire('gm')
worked.Oh, make sure to update NPM. You should run this with permissions
sudo npm i -g npm
on windows you will need to open cmd with admin privileges.