2

I have some small images that tiled together make a fullsize image. The tiles are saved on the server. I would like to stitch the tiles together in the right position and create 1 image file on disk made up of all the tile files. How can I do this in nodejs?

Thanks

zumzum
  • 17,984
  • 26
  • 111
  • 172

2 Answers2

3

Your best bet is probably to invoke a tool like ImageMagick, which has a montage command that does exactly what you're looking for.

This would be fairly straightforward to implement yourself, but I see that this fork of node-imagemagick has montage support.

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
  • nice; I can't believe that's been around since November; node is sure screaming along on libs! – Kato Feb 07 '12 at 21:52
  • I see, that looks like good way. I am trying to use the forked version of image magick that has the montage feature but I am not sure how to get a forked version of npm module install. Any hints? – zumzum Feb 07 '12 at 22:45
  • You should be able to add it as a dependency in your `package.json` with the GitHub tarball URL, e.g. `"dependencies" : { "imagemagick" : "https://github.com/enobrev/node-imagemagick/tarball/master" }`. See `npm help json` ([also here](http://npmjs.org/doc/json.html#dependencies)) for more information. – Jordan Running Feb 07 '12 at 23:20
  • I tried to do what it's shown here but no luck yet.....http://debuggable.com/posts/how-to-fork-patch-npm-modules:4e2eb9f3-e584-44be-b1a9-3db7cbdd56cb But I guess this is another question. – zumzum Feb 08 '12 at 00:00
0

Since node.js doesn't have a graphics editing suite, your best path would be to

You could call an external script, using java, using php, or the language you feel most comfortable hacking with.

There's plenty of material on how to run a script from node.js, so I won't mess around with that here.

However, I would suggest that you pass a temporary filename as an argument to the script, then when it finishes executing, go get that file rather than trying to read back the binary as a return value or something equally convoluted.

Community
  • 1
  • 1
Kato
  • 40,352
  • 6
  • 119
  • 149