如何将图像缓冲区数据传递给()GraphicsMagic中的gm [英] how to pass image buffer data to gm in() GraphicsMagic

查看:105
本文介绍了如何将图像缓冲区数据传递给()GraphicsMagic中的gm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var buf = require('fs').readFileSync('test.jpg');

gm().in('-page', '+0+0').in(buf,'test.jpg').write('output.jpg', function (err) {
     if (err) console.log(err);
})

在这种情况下,我想将缓冲区数据作为输入传递给 gm.in()方法。

in this case i want to pass buffer data as input to the gm.in() method.

以下是我正在引用的链接,但在其中,图像路径用作输入。我想使用缓冲区数据作为输入。我该怎么做?

Below is the link I'm referencing but in it, an image path is used as an input. I want to use buffer data as an input. How can I do this?

使用Node.js和GraphicsMagick将四个图像拼接在一起

推荐答案

无需修改源代码GraphicsMagick本身,你不能。 gm 模块通过命令行与GraphicsMagick程序交互。您通过 .in()方法传递的参数将被转换为命令行参数。 GraphicsMagick程序只接受此参数的文件名,不会尝试处理任何直接形式的数据。

Without modifying the source of GraphicsMagick itself, you can't. The gm module interacts with the GraphicsMagick program through the command line. The arguments you're passing through the .in() method are being converted into command-line arguments. The GraphicsMagick program only accepts filenames for this argument and will not attempt to process any direct form of data.

如果你真的需要在没有文件系统的情况下完成这项工作,你可以总是下载GraphicsMagick源代码并更改CLI以接受某种形式的数据blob而不是此参数的URL。

If you really needed to make this work without the filesystem, you could always download the GraphicsMagick source code and change the CLI to accept some form of data blob instead of a URL for this argument.

这篇关于如何将图像缓冲区数据传递给()GraphicsMagic中的gm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆