Search code examples
node.jsgraphicsmagick

nodejs gm module script to split a big multipage tiff file in multiple single images


When executed from command line, invoking directly GraphicsMagick, the following instructions split correctly a big tiff multipage image in several single image files. Now I need to find the right translation to make it work with the Node.js gm module ( http://aheckmann.github.com/gm/):

gm convert +adjoin -trim input.pdf PNG8:output%03d.png

Any help would be really appreciated.


Solution

  • You can use custom arguments directly from nodejs.

    Example:

    var gm = require('gm');
    
    gm().command('convert').in('+adjoin').in(filePath).write('image%02d.jpeg', function(err) {
       // something                
    });
    

    Info: https://github.com/aheckmann/gm