Search code examples
javascriptnode.jsgraphicsmagick

GraphicsMagick For Node - Get Multi-Page TIF Page Frame


I have a java script where I can pass in a single page TIF, and it converts to a JPEG properly. However, I am having trouble finding whether "GraphicsMagick For Node" (https://github.com/aheckmann/gm) has the ability to extract a single page (using the "pageNumber" parameter) out of a multi-page TIFF and convert to JPEG. I.e., navigate to frame and extract just that one page. I cannot find anywhere else on this site. Thanks!

function GetImageAndConvert(input, output, pageNumber, idx, callback)
{
    gm(input).setFormat('jpeg').noProfile().toBuffer(function(err, buffer) 
    {
         if (!err) 
         {
              console.log('Converted to jpeg');
         }
         else
         {
           // record error here
         }

         callback(buffer, idx);
    });
}

Solution

  • Answering my own question. Completely missed it in the documentation:

    gm("img.png").selectFrame(0)