如何为graphicsmagick配置JPEG委托? [英] How do I configure a JPEG delegate for graphicsmagick?

查看:143
本文介绍了如何为graphicsmagick配置JPEG委托?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将图像裁剪到指定的像素区域。我想使用 https://中的 gm 模块github.com/aheckmann/gm
我正在运行Linux Mint 13和node.js v0.9.4pre。

I want to crop an image to a specified pixel region. I'd like to use the gm module from https://github.com/aheckmann/gm. I am running Linux Mint 13 and node.js v0.9.4pre.

我遇到一个错误,听起来像graphicsmagick不知道jpegs :

I am running into an error that sounds like graphicsmagick doesn't know about jpegs:

Error: Command failed: gm convert: No decode delegate for this image format (./assets/images/temp/2aadd4379e1cf2b59429994270db2a8a.jpg)

果然, gm convert -list格式显示没有jpeg委托:

Sure enough, gm convert -list formats shows no jpeg delegate:

<snip>
     IPTC P  rw-  IPTC Newsphoto
 IPTCTEXT P  rw-  IPTC Newsphoto text format
IPTCWTEXT P  rw-  IPTC Newsphoto text format
      K25 S  r--  Kodak Photo RAW
<snip>

graphicsmagick有 ftp文件夹,包含代理的源代码(带有自述。)所以我按照随附的安装文档中的建议下载,解压缩并安装 jpegsrc.v6b.tar.gz 我的源文件。

graphicsmagick has a ftp folder containing source code for delegates (with a readme.) So I downloaded, untarred, and installed jpegsrc.v6b.tar.gz as suggested in both the install document that came with my source files.

我很确定已经安装了jpeg库 cjpeg djpeg 或许其他的东西。但是没有 make uninstall 或我发现的清单。我还没有尝试过安装任何其他版本的jpeg库。我在安装jpeg库后卸载并重建了graphicsmagick。

I'm pretty sure the jpeg library installed cjpeg and djpeg and perhaps other stuff. However there is no make uninstall or manifest that I found. I haven't tried installing any other versions of the jpeg library over this one. I uninstalled and rebuilt graphicsmagick after installing the jpeg library.

但是, gm转换列表格式中没有列出JPEG委托

我正在从Imagemagick迁移,即使没有安装此库,也没有任何调整jpeg的问题。

I am migrating from Imagemagick which never had any problems resizing jpegs, even without my installing this library.

我必须做些什么才能让图形处理jpeg?

这是怎样的我正在调用gm:

Here's how I am invoking gm:

    var gmagic = require('gm');
    gmagic(cfg.tmpPath)
    .crop(h,w,x0,y0)
    .write(cfg.croppedPath, function(err){
      if(err){ done(err) } 
        else { done(null, cfg.croppedPath) };
    });   

以下是我用来安装jpeg库和graphicsmagick的命令:

Here are the commands I used to install the jpeg library and graphicsmagick:

$ cd ~/source
$ wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
$ tar -xzvf jpegsrc.v6b.tar.gz
$ cd jpeg-6b
$ ./configure
$ make
$ sudo make install

$ cd ~/source
$ wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-1.3.18.tar.xz
$ tar -xJvf GraphicsMagick-1.3.18.tar.xz
$ cd GraphicsMagick-1.3.18
$ ./configure
$ make
$ sudo make install

$ npm install gm


推荐答案

我通过告诉gm库使用找到了成功的解决方法imagemagick二进制文件而不是默认的graphmagic二进制文件:

I found a successful workaround by telling the gm library to use imagemagick binaries instead of default graphicsmagic binaries:

var gmagic   = require('gm');
var imagic   = gmagic.subClass({imageMagick: true});
...
imagic(cfg.tmpPath)
.crop(h,w,x0,y0)
.write(cfg.croppedPath, function(err, stdout, stderr, command){
  if(err){ next(err) }
  else { next(null, raft) };
});

这篇关于如何为graphicsmagick配置JPEG委托?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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