简体   繁体   中英

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. Ie, 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);
    });
}

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM