2012-09-13 10:15 2496人阅读 评论(0) 收藏 举报
 分类:
java技术(52) 
简介 
        GraphicsMagick号称图像处理领域的瑞士军刀。 短小精悍的代码却提供了一个鲁棒、高效的工具和库集合,来处理图像的读取、写入和操作,支持超过88中图像格式,包括重要的DPX、GIF、JPEG、JPEG-2000、PNG、PDF、PNM和TIFF。 
        通过使用OpenMP可是利用多线程进行图片处理,增强了通过扩展CPU提高处理能力。GraphicsMagick可以再绝大多数的平台上使用,Linux、Mac、Windows都没有问题。

GraphicsMagick支持大图片的处理,并且已经做过GB级别的图像处理实验。GraphicsMagick能够动态的生成图片,特别适用于互联网的应用。可以用来处理调整尺寸、旋转、加亮、颜色调整、增加特效等方面。GaphicsMagick不仅支持命令行的模式,同时也支持C、C++、Perl、PHP、Tcl、Ruby等的调用。事实上,GraphicsMagick是从 ImageMagick 5.5.2 分支出来的,但是现在他变得更稳定和优秀,下面就是两个之间的一些比较。

安装

  • tar -xvf GraphicsMagick-1.3.12.tar
  • ./configure --without-prel --enable-shared --disable-openmp
  • make
  • make install

示例:GraphicsMagick+im4java压缩图片

  1. /**
  2. * 先缩放,后居中切割图片
  3. * @param srcPath 源图路径
  4. * @param desPath 目标图保存路径
  5. * @param rectw 待切割在宽度
  6. * @param recth 待切割在高度
  7. * @throws IM4JavaException
  8. * @throws InterruptedException
  9. * @throws IOException
  10. */
  11. public static void cropImageCenter(String srcPath, String desPath, int rectw, int recth) throws IOException, InterruptedException, IM4JavaException{
  12. IMOperation op = new IMOperation();
  13. op.addImage();
  14. op.resize(rectw, recth, '^').gravity("center").extent(rectw, recth);
  15. op.addImage();
  16. ConvertCmd convert = new ConvertCmd(true);
  17. convert.run(op, srcPath, desPath);
  18. }
  1. /**
  2. * 先缩放,后居中切割图片
  3. * @param srcPath 源图路径
  4. * @param desPath 目标图保存路径
  5. * @param rectw 待切割在宽度
  6. * @param recth 待切割在高度
  7. * @throws IM4JavaException
  8. * @throws InterruptedException
  9. * @throws IOException
  10. */
  11. public static void cropImageCenter(String srcPath, String desPath, int rectw, int recth) throws IOException, InterruptedException, IM4JavaException{
  12. IMOperation op = new IMOperation();
  13. op.addImage();
  14. op.resize(rectw, recth, '^').gravity("center").extent(rectw, recth);
  15. op.addImage();
  16. ConvertCmd convert = new ConvertCmd(true);
  17. convert.run(op, srcPath, desPath);
  18. }

问题 
        如果是windows环境安装则需要设置path环境配置,如D:\Program Files\GraphicsMagick-1.3.12-Q16;(此为GraphicsMagick的安装目录),各种版本官网下载

报错信息"gm convert: No decode delegate for this image format (abc.jpg)”系图片库缺失所致

引用
http://qing.weibo.com/1838939461/6d9bfd4533000j33.html 
./configure结果

GraphicsMagick is configured as follows. Please verify that this 
configuration matches your expectations.

Host system type : x86_64-unknown-linux-gnu 
Build system type : x86_64-unknown-linux-gnu

Option            Configure option              Configured value 
----------------------------------------------------------------- 
Shared libraries  --enable-shared=no            no 
Static libraries  --enable-static=yes           yes 
GNU ld            --with-gnu-ld=yes             yes 
Quantum depth     --with-quantum-depth=8        8

Delegate Configuration: 
BZLIB             --with-bzlib=yes              no 
DPS               --with-dps=yes                no 
FlashPIX          --with-fpx=no                 no 
FreeType 2.0      --with-ttf=yes                no 
Ghostscript       None                          gs (unknown) 
Ghostscript fonts --with-gs-font-dir=default    none 
Ghostscript lib   --with-gslib=no               no 
JBIG              --with-jbig=yes               no 
JPEG v1           --with-jpeg=yes               no (需安装 jpeg delegate library) 
JPEG-2000         --with-jp2=yes                no 
LCMS              --with-lcms=yes               no 
Magick++          --with-magick-plus-plus=yes   yes 
PERL              --with-perl=no                no 
PNG               --with-png=yes                no(需安装 png delegate library) 
TIFF              --with-tiff=yes               no 
TRIO              --with-trio=yes               no 
Windows fonts     --with-windows-font-dir=      none 
WMF               --with-wmf=yes                no 
X11               --with-x=                     no 
XML               --with-xml=yes                no 
ZLIB              --with-zlib=yes               yes 
make 
sudo make install 
Delegate Library安装

JPEG delegate library 
> gm convert 470f1bb8c5a98.jpg -resize 100x100 out.jpg 
gm convert: No decode delegate for this image format (470f1bb8c5a98.jpg). 
官方建议:This exception indicates that an external delegate library or its headers were not available when ImageMagick was built. To add support for the image format, download and install the requisite delegate library and its header files and reconfigure, rebuild, and reinstall ImageMagick. As an example, lets add support for the JPEG image format. First we install the JPEG RPMS: 
原因是没有安装jpeg的包,这个可以在之前configure的结果中看出来,此时GraphicsMagick需要重新configure及build。 
1)在GraphicsMagick官方网站提供的delegates下载页面中找到jpeg的包:libjpeg-6b.tar.gz。 
2)安装jpeg delegate library. configure -> make -> sudo make install 
3)重新安装GraphicsMagick (configure时会发现jpeg已安装)

PNG delegate library 
gm convert: No decode delegate for this image format (ben3.png). 
1)在sourceforge下载libpng-1.4.7.tar.gz  (libpng-1.5.2.tar.gz 版本装上后,GraphicsMagick 在make时会报一个‘去引用’的错,原因未知) 
2)安装png delegate library. configure -> make -> sudo make install 
3)重新安装GraphicsMagick (configure时会发现png已安装) 
注: 由于之前安装过一次libpng-1.5.2,rm /usr/local/lib/libpng*,在重新安装了1.4.7后,仍有错误:gm: error while loading shared libraries: libpng14.so.14: cannot open shared object file: No such file or directory. 
运行sudo ldconfig进行自动清理。

资料 
IM4JAVA+GraphicsMagick处理网站图片:http://javantsky.iteye.com/blog/747807 
关于GraphicsMagick+im4java的研究心得:http://yunduxiaocheng-gmail-com.iteye.com/blog/919457 
GraphicsMagick+im4java图片处理方法:http://www.beiqiu.com/article/106.html 
GraphicsMagick官网:http://www.graphicsmagick.org/index.html 
GraphicsMagick官网delegates下载页面:ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/delegates/

GraphicsMagick 号称图像处理领域的瑞士军刀的更多相关文章

  1. Htop/Glances/Dstat性能测试系统监控工具领域的瑞士军刀

    原文链接:https://mp.weixin.qq.com/s/TvfzIy4uXHPOFQ1h5Q4KWg 建议点击原文链接查看 续上篇分享的[性能测试工具],今天整理了常用的系统监控工具,当然有特 ...

  2. GraphicsMagick为图片添加水印

    GraphicsMagick号称图像处理领域的瑞士军刀.提供了健壮及高效的图像处理工具包和库,支持超过88种主流图片格式包括:BMP,GIF,JPEG,JPEG-2000,PNG,PDF,PNM,TI ...

  3. 转:GraphicsMagick介绍及安装

    原文来自于:http://www.cnblogs.com/cocowool/archive/2010/08/16/1800954.html GraphicsMagick 当前稳定版本:1.3.12(发 ...

  4. 安装 GraphicsMagick

    yum -y install GraphicsMagick GraphicsMagick-devel 实际试了试,上面yum的方式不好使,下面是我实际安装过程: 1.下载最新版 wget ftp:// ...

  5. Python10个图像处理工具

    原文地址:https://cloud.tencent.com/developer/article/1498116 译者 | 小韩 来源 | towardsdatascience [磐创AI导读]:本篇 ...

  6. 十个python图像处理工具

    介绍 如今的世界存在了大量的数据,图像数据是重要的组成部分.如果要利用这些图片,需要对图像进行处理,提高图片质量或提取图片内容信息. 图像处理的常见操作包括图像显示,基本操作如裁剪,翻转,旋转等,图像 ...

  7. 图像处理、计算机视觉与模式识别“SCI期刊和顶级会议”总结

    期刊: best (1) IEEE Transactions on Pattern Analysis and Machine Intelligence,IEEE模式分析与机器智能汇刊,简称PAMI,是 ...

  8. MATLAB数字图像处理(一)基础操作和傅立叶变换

    数字图像处理是一门集计算机科学.光学.数学.物理学等多学科的综合科学.随着计算机科学的发展,数字图像处理技术取得了巨大的进展,呈现出强大的生命力,已经在多种领域取得了大量的应用,推动了社会的发展.其中 ...

  9. 计算机视觉和模式识别领域SCI期刊介绍

    原帖地址: http://blog.sciencenet.cn/blog-370458-750306.html 关于计算机视觉和模式识别领域的期刊并不是很多,下面我收集了一些该领域的代表性期刊,并介绍 ...

随机推荐

  1. Java 阻塞

    对于用ServerSocket 及 Socket 编写的服务器程序和客户程序, 他们在运行过程中常常会阻塞. 例如, 当一个线程执行 ServerSocket 的accept() 方法时, 假如没有客 ...

  2. mysqldump备份时,--master-data选项的作用是什么?

    需求描述: 今天在研究mysql的备份和恢复,使用mysqldump备份数据库时,用到--master-data选项, 在此,测试并记录选项的作用 测试过程: 1.不使用--master-data进行 ...

  3. java总结(1)——java的特点

    之前学习java仅仅是单纯的学习,老师要求学习.所以就学习.可是没有细致考虑过java的一些特别之处,比方,我们为什么要学习java而不是其它的语言,它必定有选择它的特点.所以,从如今開始,仅仅有埋头 ...

  4. MySQL<数据库的高级操作>

    数据库的高级操作 MySQL提供了一个mysqldump命令,它可以实现数据的备份 数据的备份 1.备份单个数据库 mysqldump -uusername -ppassword dbname [tb ...

  5. POST提交表单,本地Windows测试无乱码,而将项目部署到服务器端产生乱码原因之一

    项目在Windows机上eclipse发布至tomcat测试没有问题,表单提交到数据库的中文都能正常显示,而将项目部署到服务器上时,出现中文乱码 确认POST提交都使用了request.setChar ...

  6. 对C语言进行调试的最好方法是什么?

    要了解调试程序的最好方法,首先要分析一下调试过程的三个要素: 应该用什么工具调试一个程序? 用什么办法才能找出程序中的错误? 怎样才能从一开始就避免错误? 应该用什么工具调试一个程序? 有经验的程序员 ...

  7. orcale增量全量实时同步mysql可支持多库使用Kettle实现数据实时增量同步

    1. 时间戳增量回滚同步 假定在源数据表中有一个字段会记录数据的新增或修改时间,可以通过它对数据在时间维度上进行排序.通过中间表记录每次更新的时间戳,在下一个同步周期时,通过这个时间戳同步该时间戳以后 ...

  8. Android 使用CheckBox实现多选效果

    CheckBox:复选框1.有两种状态: 选中状态(true),未选中状态(false)2.属性: android:id="@+id/checkbox" android:layou ...

  9. 报错程序包org.springframework.test.context不存在

    在pom.xml文件中找到 加入了依赖,但是maven update 或者Reimport后 启动还是报错 最后使出绝招: 在maven仓库的位置 找到对应的文件夹 更奇怪了 发现明明有jar包啊! ...

  10. fluentValidation集成到autofac

    废话不说直接上代码 // 首先实现ValidatorFactory public class DependencyResolverValidatorFactory : ValidatorFactory ...