简体   繁体   English

GraphicsMagick For Node-获取多页TIF页面框架

[英]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. 我有一个Java脚本,可以在其中传递单页TIF,并将其正确转换为JPEG。 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. 但是,我很难找到“ GraphicsMagick For Node”( https://github.com/aheckmann/gm )是否具有从多页TIFF中提取单个页面(使用“ pageNumber”参数)的能力,并且转换为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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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