OpenBSD之Port篇——图像处理工具ImageMagick

OpenBSD的安装、升级、更新等日常问题。

版主: chenjun天地乾坤

回复
头像
whoami
铁 Fe
帖子: 76
注册时间: 2010-06-03 13:23

OpenBSD之Port篇——图像处理工具ImageMagick

帖子 whoami » 2010-08-30 10:06

OpenBSD下的图像处理——ImageMagick
这里仅把其主页上的内容翻译了一下,感觉这个软件真是博大精深啊
ImageMagick介绍
ImageMagick® 是一个软件集合,它的功能是创建、编辑、创作位图(点阵图)图像。它可以读取、转换、产生超过100种格式的图像,包括 DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, 和 TIFF。 使用ImageMagick,你可以对图像进行转换、翻转 、镜像、旋转、缩放、剪切、变形、调整颜色、特效等多种处理, 或者写入文字、画线、画多边形、画椭圆和Bézier曲线。
ImageMagick是一个典型地利用命令行操作的软件,你也可以用自己喜欢的编程语言编写程序来利用这些功能。你可以从这些接口中选择: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp), NMagick (Neko/haXe), MagickNet (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby)或 TclMagick (Tcl/TK)。你可以通过一个语言接口, 使用ImageMagick来动态和自动地修改或创建图像。
ImageMagick是一个自由的软件,以可以直接安装的二进制包或可自由使用、拷贝、修改、再分发的源代码的方式提供。它以一个类似 Apache 2.0 风格的 license 的形式分发, 这个许可证是经 OSI 认可并由 OSSCC 推荐的。
ImageMagick开发团队确保一个稳定的 API 和 ABI。在每个ImageMagick版本发行前, 我们都要执行一次全面的安全性评估,包括 memory 和 thread 错误测定以防止程序存在潜在的安全问题。

特性和功能

这里仅列出了ImageMagick功能 实例 中的一小部分:
  • 格式转换: 将图像从一个 格式转换为另一张格式 (例如:PNG 转换为 JPEG)。
  • 变形: 可以对图像进行改变大小、旋转、裁切、翻转、修剪等操作。
  • 透明: 将图像的某部分渲染为不可见。
  • 做图: 给一个图像添加文字或形状。
  • 修饰: 给一个图像添加边框或画框。
  • 特殊效果: 模糊, 锐化, 调整阀值, 或着色。
  • 动画制作: 用一组图像创建一幅GIF动画。
  • 文字或注释: 在一幅图像中插入注释行文字或美术字。
  • 图像鉴定: 描述一幅图像的格式和属性。
  • 混合: 将一幅图像置于另一幅之上。
  • 蒙太奇: 在画布上叠加一幅图像的缩略图。
  • 广义像素扭曲: 矫正, 或导致图像透视变化。
  • 形状切分方法: 特征提取, 描述形状和识别图像中的特征图案。
  • 电影技术支持: 读写用于数字电影工程的通用图像格式。
  • 图像计算: 对图像或图像通道应用一个数学表达式。
  • 离散的傅立叶变换: 实施正向或反向的傅立叶变换(DFT)。
  • 高动态范围图像: 提供真实场景范围内的强度级别,范围从最亮的阳光直射一直到最暗的阴影部分。
  • 加密或解密图像: 将原始图像可逆地加密为不可识别的图像。
  • 虚拟像素支持: 方便地访问图像区域的外围像素。
  • 大图像支持: 读取, 处理, 或写入兆、千兆或兆兆像素大小的图像。
  • 运行线程支持: ImageMagick是线程安全的,并且其核心算法启用了OpenMP技术,这样就具备了利用多处理器芯片来有效提速的优势。
  • 联合分发处理: 启用了OpenCL的特有算法,它可以让组成不同构架平台下的CPU和GPU和其它处理器联合工作,这样可以提升图像渲染速度。
  • ImageMagick应用于iPhone: 转换、编辑、压缩iPhone中的图像。
ImageMagick用法示例 向您介绍了怎样在命令行环境里完成这些任务以及实现更多的功能。也请参阅 Fred's ImageMagick Scripts: 里面有大量的命令行脚本,执行几何变换、模糊、锐化、边缘处理、降噪以及颜色控制。

有关 ImageMagick 的书籍


图片 An open source project backed by years of continual development, ImageMagick supports about 100 image formats and can perform impressive operations such as creating images from scratch; changing colors; stretching, rotating, and overlaying images; and overlaying text on images. Whether you use ImageMagick to manage the family photos or to embark on a job involving millions of images, this book provides you with the knowledge to manage your images with ease.

The Definitive Guide to ImageMagick explains all of these capabilities and more in a practical, learn-by-example fashion. You'll get comfortable using ImageMagick for any image-processing task. Through the book's coverage of the ImageMagick interfaces for C, Perl, PHP, and Ruby, you'll learn how to incorporate ImageMagick features into a variety of applications.

图片 ImageMagick Tricks by Sohail Salehi: This fast-paced and practical tutorial is packed with examples of photo manipulations, logo creation, animations, and complete web projects. With this book up your sleeve, you'll be creating spellbinding images from code in no time. The publisher, Packt, is donating a percentage of every book sold to the ImageMagick project.


用户社区

要加入 ImageMagick 的用户社区, 来这里 discourse server。你可以查阅以前的问题或回复,或者提出你自己的问题。

好了,ImageMagick如此强大,我们现在就开始领略一下它的强大功能。
首先我们安装它,环境是i386平台上的OpenBSD 4.7稳定版。我的系统不跑X或Gnome等图形环境,所以我安装ImageMagick-6.4.5.6p0-no_x11,但是有些功能需要安装X,所以你如果想尝试所有的功能就需要安装ImageMagick-6.4.5.6p0:

代码: 全选

# export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.7/packages/i386/
# pkg_add ImageMagick
Ambiguous: ImageMagick could be ImageMagick-6.4.5.6p0-no_x11 ImageMagick-6.4.5.6p0
# pkg_add ImageMagick-6.4.5.6p0-no_x11
ImageMagick-6.4.5.6p0-no_x11:jpeg-7: ok (9 to go)
ImageMagick-6.4.5.6p0-no_x11:tiff-3.8.2p5: ok (8 to go)
ImageMagick-6.4.5.6p0-no_x11:jbigkit-1.6p1: ok (7 to go)
ImageMagick-6.4.5.6p0-no_x11:png-1.2.41: ok (6 to go)
ImageMagick-6.4.5.6p0-no_x11:ghostscript-fonts-8.11p1: ok (8 to go)
ImageMagick-6.4.5.6p0-no_x11:ijs-0.35: ok (7 to go)
ImageMagick-6.4.5.6p0-no_x11:libiconv-1.13p0: ok (6 to go)
ImageMagick-6.4.5.6p0-no_x11:ghostscript-8.63p11-no_x11: ok (5 to go)
ImageMagick-6.4.5.6p0-no_x11:lcms-1.18a: ok (4 to go)
ImageMagick-6.4.5.6p0-no_x11:jasper-1.900.1p1: ok (3 to go)
ImageMagick-6.4.5.6p0-no_x11:netpbm-10.26.64: ok (2 to go)
ImageMagick-6.4.5.6p0-no_x11:bzip2-1.0.5: ok (1 to go)
ImageMagick-6.4.5.6p0-no_x11: ok
You may wish to update your font path for /usr/local/share/ghostscript/fonts
--- +ghostscript-fonts-8.11p1 -------------------
To install these fonts for X11, just make sure that the fontpath
lists the 75dpi or 100dpi bitmap fonts before the ghostscript fonts,
and make sure you have the string ":unscaled" appended to the bitmap
font's fontpath. This way, the bitmap fonts will be used if they
match, and the Type 1 versions will be used if the font needs to be
scaled. Below is the relevant section from a typical xorg.conf file.
   FontPath   "/usr/X11R6/lib/X11/fonts/misc/"
   FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
   FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
   FontPath   "/usr/local/share/ghostscript/fonts/"
   FontPath   "/usr/X11R6/lib/X11/fonts/Type1/"
#
# pkg_info
ImageMagick-6.4.5.6p0-no_x11 image processing tools
bzip2-1.0.5         block-sorting file compressor, unencumbered
ghostscript-8.63p11-no_x11 GNU PostScript interpreter
ghostscript-fonts-8.11p1 35 standard PostScript fonts with Adobe name aliases
ijs-0.35            raster image transmission library
jasper-1.900.1p1    reference implementation of JPEG-2000
jbigkit-1.6p1       lossless image compression library
jpeg-7              IJG's JPEG compression utilities
lcms-1.18a          color management library
libiconv-1.13p0     character set conversion library
netpbm-10.26.64     toolkit for converting images between different formats
png-1.2.41          library for manipulating PNG images
tiff-3.8.2p5        tools and library routines for working with TIFF images
#

关于如何添加字体的问题,请参阅这篇帖子,这个是官方的方法。但是lionux兄提供了一种更简洁的方法,也就是直接将字体拷贝到用户的home目录的 .fonts 目录下,然后fc-cache -v一下就OK了,我觉得此方法在X下也不错,请读者自行选择吧。:)

我们前面已经讲过了,ImageMagick是一组图像工具包,它包含了一组图像相关工具——我们先介绍一下identify:

identify
identify程序是一系列 ImageMagick(1) 工具集里的工具之一 。它描述一个或多个图像文件的格式和特征。它也可以判断出一个图像文件是否完整或者损坏。返回的信息包括这幅图像的号码、文件名、宽度和高度、无论图像是否有颜色分配表它还会返回图像中的颜色数量,图像包含的字节数、图像的格式 (JPEG, PNM等), 最后是她读如何处理这幅图像所花费的秒数。 通过 -verbose 参数还可以获得很多其它的特征,要想了解更新信息,请参阅http://www.imagemagick.org/script/identify.php。

我们可以使用下面的命令查看一下ImageMagick的版本,考虑到文件的实效性,可能读者所看到的版本与这里不同。

代码: 全选

# identify -version
Version: ImageMagick 6.4.5 2010-03-19 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC

我们准备一幅图像进行处理,test.png
图片

同样用identify命令还可以查看图像信息,实际上可以去掉一些图像信息,但是为了掩饰方便、我们在这里保留了这些图像信息以便讲解,首先我们不加任何参数:

代码: 全选

# identify test.png
test.png PNG 300x161 300x161+0+0 8-bit DirectClass 2.99kb
这里显示了图像名称为test.png, 格式为PNG,图像几何是300x161+0+0。8位深度,类别是DirectClass,大小为2.99kb。

要查看一下这个图像以英寸为单位的打印尺寸,这样:

代码: 全选

# identify -format "%[fx:w/72] by %[fx:h/72] inches" test.png
4.16667 by 2.23611 inches



-verbose参数则显示这个文件的所有细节信息,也是最全的信息了:

代码: 全选

# identify -verbose test.png 
Image: test.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 300x161+0+0
  Resolution: 236.22x236.22
  Print size: 1.27x0.681568
  Units: PixelsPerCentimeter
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 1-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    red:
      min: 255 (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: 0 (0)
    green:
      min: 110 (0.431373)
      max: 255 (1)
      mean: 198.684 (0.779155)
      standard deviation: 63.8309 (0.250317)
    blue:
      min: 0 (0)
      max: 255 (1)
      mean: 144.848 (0.56803)
      standard deviation: 124.839 (0.489565)
  Histogram:
     26579: (255,255,255) #FFFFFF white
     18488: (255,125,  0) #FF7D00 rgb(255,125,0)
       306: (255,119,  0) #FF7700 rgb(255,119,0)
       272: (255,159, 66) #FF9F42 rgb(255,159,66)
       231: (255,117,  0) #FF7500 rgb(255,117,0)
       224: (255,118,  0) #FF7600 rgb(255,118,0)
       218: (255,120,  0) #FF7800 rgb(255,120,0)
       165: (255,221,189) #FFDDBD rgb(255,221,189)
       153: (255,122,  0) #FF7A00 rgb(255,122,0)
       136: (255,179,105) #FFB369 rgb(255,179,105)
       126: (255,124,  0) #FF7C00 rgb(255,124,0)
       101: (255,123,  0) #FF7B00 rgb(255,123,0)
       101: (255,174, 97) #FFAE61 rgb(255,174,97)
        83: (255,246,237) #FFF6ED rgb(255,246,237)
        77: (255,134, 18) #FF8612 rgb(255,134,18)
        75: (255,205,158) #FFCD9E rgb(255,205,158)
        69: (255,248,241) #FFF8F1 rgb(255,248,241)
        67: (255,138, 25) #FF8A19 rgb(255,138,25)
        59: (255,232,211) #FFE8D3 rgb(255,232,211)
        58: (255,127,  3) #FF7F03 rgb(255,127,3)
        56: (255,140, 30) #FF8C1E rgb(255,140,30)
        56: (255,249,244) #FFF9F4 rgb(255,249,244)
        47: (255,190,128) #FFBE80 rgb(255,190,128)
        27: (255,121,  0) #FF7900 rgb(255,121,0)
        21: (255,128,  6) #FF8006 rgb(255,128,6)
        21: (255,152, 54) #FF9836 rgb(255,152,54)
        20: (255,235,215) #FFEBD7 rgb(255,235,215)
        12: (255,116,  0) #FF7400 rgb(255,116,0)
         6: (255,133, 16) #FF8510 rgb(255,133,16)
         6: (255,150, 49) #FF9631 rgb(255,150,49)
         6: (255,250,245) #FFFAF5 rgb(255,250,245)
         5: (255,127,  4) #FF7F04 rgb(255,127,4)
         5: (255,244,233) #FFF4E9 rgb(255,244,233)
         4: (255,202,153) #FFCA99 rgb(255,202,153)
         4: (255,206,159) #FFCE9F rgb(255,206,159)
         4: (255,229,205) #FFE5CD rgb(255,229,205)
         4: (255,230,206) #FFE6CE rgb(255,230,206)
         4: (255,233,212) #FFE9D4 rgb(255,233,212)
         4: (255,233,213) #FFE9D5 rgb(255,233,213)
         4: (255,255,254) #FFFFFE rgb(255,255,254)
         3: (255,124,  4) #FF7C04 rgb(255,124,4)
         3: (255,126,  2) #FF7E02 rgb(255,126,2)
         3: (255,133, 17) #FF8511 rgb(255,133,17)
         3: (255,146, 41) #FF9229 rgb(255,146,41)
         3: (255,146, 42) #FF922A rgb(255,146,42)
         3: (255,179,107) #FFB36B rgb(255,179,107)
         3: (255,186,120) #FFBA78 rgb(255,186,120)
         3: (255,220,186) #FFDCBA rgb(255,220,186)
         3: (255,242,229) #FFF2E5 rgb(255,242,229)
         3: (255,244,234) #FFF4EA rgb(255,244,234)
         3: (255,249,243) #FFF9F3 rgb(255,249,243)
         3: (255,251,247) #FFFBF7 rgb(255,251,247)
         3: (255,251,248) #FFFBF8 rgb(255,251,248)
         3: (255,253,250) #FFFDFA rgb(255,253,250)
         3: (255,253,251) #FFFDFB rgb(255,253,251)
         3: (255,254,252) #FFFEFC rgb(255,254,252)
         3: (255,254,253) #FFFEFD rgb(255,254,253)
         2: (255,114,  0) #FF7200 rgb(255,114,0)
         2: (255,115,  0) #FF7300 rgb(255,115,0)
         2: (255,126,  1) #FF7E01 rgb(255,126,1)
         2: (255,126,  3) #FF7E03 rgb(255,126,3)
         2: (255,127,  8) #FF7F08 rgb(255,127,8)
         2: (255,128, 12) #FF800C rgb(255,128,12)
         2: (255,131, 13) #FF830D rgb(255,131,13)
         2: (255,134, 21) #FF8615 rgb(255,134,21)
         2: (255,135, 19) #FF8713 rgb(255,135,19)
         2: (255,135, 20) #FF8714 rgb(255,135,20)
         2: (255,135, 25) #FF8719 rgb(255,135,25)
         2: (255,136, 21) #FF8815 rgb(255,136,21)
         2: (255,137, 23) #FF8917 rgb(255,137,23)
         2: (255,144, 37) #FF9025 rgb(255,144,37)
         2: (255,147, 44) #FF932C rgb(255,147,44)
         2: (255,148, 45) #FF942D rgb(255,148,45)
         2: (255,149, 48) #FF9530 rgb(255,149,48)
         2: (255,149, 51) #FF9533 rgb(255,149,51)
         2: (255,150, 51) #FF9633 rgb(255,150,51)
         2: (255,152, 56) #FF9838 rgb(255,152,56)
         2: (255,153, 55) #FF9937 rgb(255,153,55)
         2: (255,155, 66) #FF9B42 rgb(255,155,66)
         2: (255,171, 91) #FFAB5B rgb(255,171,91)
         2: (255,173, 94) #FFAD5E rgb(255,173,94)
         2: (255,173, 96) #FFAD60 rgb(255,173,96)
         2: (255,175, 97) #FFAF61 rgb(255,175,97)
         2: (255,176,101) #FFB065 rgb(255,176,101)
         2: (255,179,106) #FFB36A rgb(255,179,106)
         2: (255,184,115) #FFB873 rgb(255,184,115)
         2: (255,188,125) #FFBC7D rgb(255,188,125)
         2: (255,189,125) #FFBD7D rgb(255,189,125)
         2: (255,193,133) #FFC185 rgb(255,193,133)
         2: (255,194,136) #FFC288 rgb(255,194,136)
         2: (255,199,144) #FFC790 rgb(255,199,144)
         2: (255,202,152) #FFCA98 rgb(255,202,152)
         2: (255,208,163) #FFD0A3 rgb(255,208,163)
         2: (255,209,167) #FFD1A7 rgb(255,209,167)
         2: (255,214,175) #FFD6AF rgb(255,214,175)
         2: (255,215,177) #FFD7B1 rgb(255,215,177)
         2: (255,219,184) #FFDBB8 rgb(255,219,184)
         2: (255,219,185) #FFDBB9 rgb(255,219,185)
         2: (255,222,191) #FFDEBF rgb(255,222,191)
         2: (255,224,194) #FFE0C2 rgb(255,224,194)
         2: (255,224,195) #FFE0C3 rgb(255,224,195)
         2: (255,227,201) #FFE3C9 rgb(255,227,201)
         2: (255,228,202) #FFE4CA rgb(255,228,202)
         2: (255,232,209) #FFE8D1 rgb(255,232,209)
         2: (255,232,210) #FFE8D2 rgb(255,232,210)
         2: (255,233,211) #FFE9D3 rgb(255,233,211)
         2: (255,234,213) #FFEAD5 rgb(255,234,213)
         2: (255,235,216) #FFEBD8 rgb(255,235,216)
         2: (255,236,218) #FFECDA rgb(255,236,218)
         2: (255,237,219) #FFEDDB rgb(255,237,219)
         2: (255,240,225) #FFF0E1 rgb(255,240,225)
         2: (255,240,226) #FFF0E2 rgb(255,240,226)
         2: (255,241,227) #FFF1E3 rgb(255,241,227)
         2: (255,242,230) #FFF2E6 rgb(255,242,230)
         2: (255,243,232) #FFF3E8 rgb(255,243,232)
         2: (255,245,235) #FFF5EB rgb(255,245,235)
         2: (255,245,236) #FFF5EC rgb(255,245,236)
         2: (255,245,237) #FFF5ED rgb(255,245,237)
         2: (255,247,238) #FFF7EE rgb(255,247,238)
         2: (255,247,239) #FFF7EF rgb(255,247,239)
         2: (255,250,246) #FFFAF6 rgb(255,250,246)
         2: (255,252,248) #FFFCF8 rgb(255,252,248)
         2: (255,252,249) #FFFCF9 rgb(255,252,249)
         2: (255,253,252) #FFFDFC rgb(255,253,252)
         2: (255,254,254) #FFFEFE rgb(255,254,254)
         1: (255,110,  0) #FF6E00 rgb(255,110,0)
         1: (255,111,  0) #FF6F00 rgb(255,111,0)
         1: (255,112,  0) #FF7000 rgb(255,112,0)
         1: (255,113,  0) #FF7100 rgb(255,113,0)
         1: (255,122,  1) #FF7A01 rgb(255,122,1)
         1: (255,122,  2) #FF7A02 rgb(255,122,2)
         1: (255,122,  4) #FF7A04 rgb(255,122,4)
         1: (255,123,  4) #FF7B04 rgb(255,123,4)
         1: (255,124,  1) #FF7C01 rgb(255,124,1)
         1: (255,124,  2) #FF7C02 rgb(255,124,2)
         1: (255,124,  3) #FF7C03 rgb(255,124,3)
         1: (255,124,  6) #FF7C06 rgb(255,124,6)
         1: (255,125,  2) #FF7D02 rgb(255,125,2)
         1: (255,125,  3) #FF7D03 rgb(255,125,3)
         1: (255,125,  5) #FF7D05 rgb(255,125,5)
         1: (255,126,  4) #FF7E04 rgb(255,126,4)
         1: (255,126,  6) #FF7E06 rgb(255,126,6)
         1: (255,127,  5) #FF7F05 rgb(255,127,5)
         1: (255,127,  6) #FF7F06 rgb(255,127,6)
         1: (255,127,  9) #FF7F09 rgb(255,127,9)
         1: (255,127, 10) #FF7F0A rgb(255,127,10)
         1: (255,128,  8) #FF8008 rgb(255,128,8)
         1: (255,128, 18) #FF8012 rgb(255,128,18)
         1: (255,130,  9) #FF8209 rgb(255,130,9)
         1: (255,130, 14) #FF820E rgb(255,130,14)
         1: (255,130, 15) #FF820F rgb(255,130,15)
         1: (255,130, 18) #FF8212 rgb(255,130,18)
         1: (255,131, 11) #FF830B rgb(255,131,11)
         1: (255,131, 12) #FF830C rgb(255,131,12)
         1: (255,131, 18) #FF8312 rgb(255,131,18)
         1: (255,132, 13) #FF840D rgb(255,132,13)
         1: (255,132, 16) #FF8410 rgb(255,132,16)
         1: (255,133, 18) #FF8512 rgb(255,133,18)
         1: (255,133, 19) #FF8513 rgb(255,133,19)
         1: (255,134, 17) #FF8611 rgb(255,134,17)
         1: (255,134, 19) #FF8613 rgb(255,134,19)
         1: (255,134, 23) #FF8617 rgb(255,134,23)
         1: (255,135, 21) #FF8715 rgb(255,135,21)
         1: (255,135, 23) #FF8717 rgb(255,135,23)
         1: (255,135, 24) #FF8718 rgb(255,135,24)
         1: (255,135, 26) #FF871A rgb(255,135,26)
         1: (255,136, 24) #FF8818 rgb(255,136,24)
         1: (255,136, 25) #FF8819 rgb(255,136,25)
         1: (255,137, 24) #FF8918 rgb(255,137,24)
         1: (255,138, 29) #FF8A1D rgb(255,138,29)
         1: (255,138, 30) #FF8A1E rgb(255,138,30)
         1: (255,138, 31) #FF8A1F rgb(255,138,31)
         1: (255,139, 27) #FF8B1B rgb(255,139,27)
         1: (255,139, 29) #FF8B1D rgb(255,139,29)
         1: (255,139, 32) #FF8B20 rgb(255,139,32)
         1: (255,140, 28) #FF8C1C rgb(255,140,28)
         1: (255,140, 29) #FF8C1D rgb(255,140,29)
         1: (255,140, 32) #FF8C20 rgb(255,140,32)
         1: (255,140, 36) #FF8C24 rgb(255,140,36)
         1: (255,141, 31) #FF8D1F rgb(255,141,31)
         1: (255,141, 32) #FF8D20 rgb(255,141,32)
         1: (255,142, 34) #FF8E22 rgb(255,142,34)
         1: (255,142, 38) #FF8E26 rgb(255,142,38)
         1: (255,143, 40) #FF8F28 rgb(255,143,40)
         1: (255,144, 38) #FF9026 rgb(255,144,38)
         1: (255,144, 39) #FF9027 rgb(255,144,39)
         1: (255,144, 40) #FF9028 rgb(255,144,40)
         1: (255,144, 42) #FF902A rgb(255,144,42)
         1: (255,145, 39) #FF9127 rgb(255,145,39)
         1: (255,145, 41) #FF9129 rgb(255,145,41)
         1: (255,145, 43) #FF912B rgb(255,145,43)
         1: (255,146, 40) #FF9228 rgb(255,146,40)
         1: (255,146, 45) #FF922D rgb(255,146,45)
         1: (255,147, 47) #FF932F rgb(255,147,47)
         1: (255,148, 47) #FF942F rgb(255,148,47)
         1: (255,149, 47) #FF952F rgb(255,149,47)
         1: (255,150, 50) #FF9632 rgb(255,150,50)
         1: (255,151, 52) #FF9734 rgb(255,151,52)
         1: (255,151, 55) #FF9737 rgb(255,151,55)
         1: (255,152, 52) #FF9834 rgb(255,152,52)
         1: (255,152, 53) #FF9835 rgb(255,152,53)
         1: (255,153, 56) #FF9938 rgb(255,153,56)
         1: (255,153, 58) #FF993A rgb(255,153,58)
         1: (255,154, 56) #FF9A38 rgb(255,154,56)
         1: (255,154, 58) #FF9A3A rgb(255,154,58)
         1: (255,154, 66) #FF9A42 rgb(255,154,66)
         1: (255,155, 57) #FF9B39 rgb(255,155,57)
         1: (255,155, 58) #FF9B3A rgb(255,155,58)
         1: (255,155, 59) #FF9B3B rgb(255,155,59)
         1: (255,155, 61) #FF9B3D rgb(255,155,61)
         1: (255,156, 59) #FF9C3B rgb(255,156,59)
         1: (255,156, 60) #FF9C3C rgb(255,156,60)
         1: (255,156, 61) #FF9C3D rgb(255,156,61)
         1: (255,156, 65) #FF9C41 rgb(255,156,65)
         1: (255,157, 66) #FF9D42 rgb(255,157,66)
         1: (255,158, 66) #FF9E42 rgb(255,158,66)
         1: (255,158, 69) #FF9E45 rgb(255,158,69)
         1: (255,159, 67) #FF9F43 rgb(255,159,67)
         1: (255,159, 68) #FF9F44 rgb(255,159,68)
         1: (255,159, 70) #FF9F46 rgb(255,159,70)
         1: (255,160, 68) #FFA044 rgb(255,160,68)
         1: (255,160, 69) #FFA045 rgb(255,160,69)
         1: (255,160, 70) #FFA046 rgb(255,160,70)
         1: (255,160, 71) #FFA047 rgb(255,160,71)
         1: (255,160, 72) #FFA048 rgb(255,160,72)
         1: (255,161, 70) #FFA146 rgb(255,161,70)
         1: (255,161, 73) #FFA149 rgb(255,161,73)
         1: (255,162, 72) #FFA248 rgb(255,162,72)
         1: (255,162, 74) #FFA24A rgb(255,162,74)
         1: (255,164, 79) #FFA44F rgb(255,164,79)
         1: (255,164, 81) #FFA451 rgb(255,164,81)
         1: (255,165, 78) #FFA54E rgb(255,165,78)
         1: (255,165, 79) #FFA54F rgb(255,165,79)
         1: (255,166, 80) #FFA650 rgb(255,166,80)
         1: (255,166, 82) #FFA652 rgb(255,166,82)
         1: (255,167, 82) #FFA752 rgb(255,167,82)
         1: (255,167, 85) #FFA755 rgb(255,167,85)
         1: (255,169, 91) #FFA95B rgb(255,169,91)
         1: (255,170, 88) #FFAA58 rgb(255,170,88)
         1: (255,170, 95) #FFAA5F rgb(255,170,95)
         1: (255,171, 89) #FFAB59 rgb(255,171,89)
         1: (255,172, 92) #FFAC5C rgb(255,172,92)
         1: (255,172, 93) #FFAC5D rgb(255,172,93)
         1: (255,174, 95) #FFAE5F rgb(255,174,95)
         1: (255,174, 96) #FFAE60 rgb(255,174,96)
         1: (255,174, 99) #FFAE63 rgb(255,174,99)
         1: (255,175, 98) #FFAF62 rgb(255,175,98)
         1: (255,175, 99) #FFAF63 rgb(255,175,99)
         1: (255,175,100) #FFAF64 rgb(255,175,100)
         1: (255,175,104) #FFAF68 rgb(255,175,104)
         1: (255,176,100) #FFB064 rgb(255,176,100)
         1: (255,176,102) #FFB066 rgb(255,176,102)
         1: (255,176,103) #FFB067 rgb(255,176,103)
         1: (255,176,105) #FFB069 rgb(255,176,105)
         1: (255,177,102) #FFB166 rgb(255,177,102)
         1: (255,177,103) #FFB167 rgb(255,177,103)
         1: (255,178,103) #FFB267 rgb(255,178,103)
         1: (255,178,104) #FFB268 rgb(255,178,104)
         1: (255,178,105) #FFB269 rgb(255,178,105)
         1: (255,178,106) #FFB26A rgb(255,178,106)
         1: (255,180,109) #FFB46D rgb(255,180,109)
         1: (255,180,110) #FFB46E rgb(255,180,110)
         1: (255,181,109) #FFB56D rgb(255,181,109)
         1: (255,181,110) #FFB56E rgb(255,181,110)
         1: (255,182,113) #FFB671 rgb(255,182,113)
         1: (255,182,114) #FFB672 rgb(255,182,114)
         1: (255,184,118) #FFB876 rgb(255,184,118)
         1: (255,185,119) #FFB977 rgb(255,185,119)
         1: (255,185,120) #FFB978 rgb(255,185,120)
         1: (255,186,119) #FFBA77 rgb(255,186,119)
         1: (255,187,124) #FFBB7C rgb(255,187,124)
         1: (255,187,125) #FFBB7D rgb(255,187,125)
         1: (255,188,123) #FFBC7B rgb(255,188,123)
         1: (255,188,124) #FFBC7C rgb(255,188,124)
         1: (255,188,127) #FFBC7F rgb(255,188,127)
         1: (255,189,127) #FFBD7F rgb(255,189,127)
         1: (255,189,128) #FFBD80 rgb(255,189,128)
         1: (255,190,127) #FFBE7F rgb(255,190,127)
         1: (255,191,133) #FFBF85 rgb(255,191,133)
         1: (255,192,130) #FFC082 rgb(255,192,130)
         1: (255,192,131) #FFC083 rgb(255,192,131)
         1: (255,196,140) #FFC48C rgb(255,196,140)
         1: (255,196,141) #FFC48D rgb(255,196,141)
         1: (255,198,144) #FFC690 rgb(255,198,144)
         1: (255,199,145) #FFC791 rgb(255,199,145)
         1: (255,201,149) #FFC995 rgb(255,201,149)
         1: (255,202,151) #FFCA97 rgb(255,202,151)
         1: (255,203,154) #FFCB9A rgb(255,203,154)
         1: (255,203,155) #FFCB9B rgb(255,203,155)
         1: (255,203,156) #FFCB9C rgb(255,203,156)
         1: (255,204,156) #FFCC9C rgb(255,204,156)
         1: (255,207,161) #FFCFA1 rgb(255,207,161)
         1: (255,209,165) #FFD1A5 rgb(255,209,165)
         1: (255,210,166) #FFD2A6 rgb(255,210,166)
         1: (255,211,169) #FFD3A9 rgb(255,211,169)
         1: (255,212,172) #FFD4AC rgb(255,212,172)
         1: (255,213,173) #FFD5AD rgb(255,213,173)
         1: (255,214,176) #FFD6B0 rgb(255,214,176)
         1: (255,214,177) #FFD6B1 rgb(255,214,177)
         1: (255,215,175) #FFD7AF rgb(255,215,175)
         1: (255,215,176) #FFD7B0 rgb(255,215,176)
         1: (255,216,180) #FFD8B4 rgb(255,216,180)
         1: (255,217,179) #FFD9B3 rgb(255,217,179)
         1: (255,219,186) #FFDBBA rgb(255,219,186)
         1: (255,220,187) #FFDCBB rgb(255,220,187)
         1: (255,221,188) #FFDDBC rgb(255,221,188)
         1: (255,222,189) #FFDEBD rgb(255,222,189)
         1: (255,222,190) #FFDEBE rgb(255,222,190)
         1: (255,225,197) #FFE1C5 rgb(255,225,197)
         1: (255,226,199) #FFE2C7 rgb(255,226,199)
         1: (255,227,200) #FFE3C8 rgb(255,227,200)
         1: (255,228,201) #FFE4C9 rgb(255,228,201)
         1: (255,228,203) #FFE4CB rgb(255,228,203)
         1: (255,229,204) #FFE5CC rgb(255,229,204)
         1: (255,230,207) #FFE6CF rgb(255,230,207)
         1: (255,231,208) #FFE7D0 rgb(255,231,208)
         1: (255,231,209) #FFE7D1 rgb(255,231,209)
         1: (255,234,214) #FFEAD6 rgb(255,234,214)
         1: (255,234,215) #FFEAD7 rgb(255,234,215)
         1: (255,235,214) #FFEBD6 rgb(255,235,214)
         1: (255,236,219) #FFECDB rgb(255,236,219)
         1: (255,237,220) #FFEDDC rgb(255,237,220)
         1: (255,237,222) #FFEDDE rgb(255,237,222)
         1: (255,238,221) #FFEEDD rgb(255,238,221)
         1: (255,238,222) #FFEEDE rgb(255,238,222)
         1: (255,239,224) #FFEFE0 rgb(255,239,224)
         1: (255,241,226) #FFF1E2 rgb(255,241,226)
         1: (255,243,230) #FFF3E6 rgb(255,243,230)
         1: (255,246,238) #FFF6EE rgb(255,246,238)
         1: (255,247,240) #FFF7F0 rgb(255,247,240)
         1: (255,248,242) #FFF8F2 rgb(255,248,242)
         1: (255,249,242) #FFF9F2 rgb(255,249,242)
         1: (255,249,245) #FFF9F5 rgb(255,249,245)
         1: (255,250,244) #FFFAF4 rgb(255,250,244)
  Rendering intent: Undefined
  Chromaticity:
    red primary: (0.63999,0.33001)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.05999)
    white point: (0.31269,0.32899)
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Page geometry: 300x161+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    create-date: 2010-08-29T18:32:26-05:00
    modify-date: 2010-08-29T23:30:30-05:00
    signature: 181eb67a7d78e21030e2de7dcb0a171822c02c7fcde1b01ade312fbee040b814
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 2.99kb
  Number pixels: 47.2kb
  Version: ImageMagick 6.4.5 2010-03-19 Q16 http://www.imagemagick.org


我们要列出可用的色彩空间,这样:

代码: 全选

# identify -list colorspace
CMY
CMYK
Gray
HSB
HSL
HWB
Lab
Log
OHTA
Rec601Luma
Rec601YCbCr
Rec709Luma
Rec709YCbCr
RGB
sRGB
Transparent
XYZ
YCbCr
YCC
YIQ
YPbPr
YUV
#


还有一些参数请自行参阅用户手册的说明:

代码: 全选

       Image Settings:
         -antialias           remove pixel-aliasing
         -authenticate value  decrypt image with this password
         -channel  type        apply option to select image chan-
       nels
         -crop geometry       cut out a rectangular region of the
       image
         -define format:option
                              define  one  or  more  image format
       options
         -density geometry    horizontal and vertical density  of
       the image
         -depth value         image depth
         -extract geometry    extract area from image
         -format "string"     output formatted image characteris-
       tics
         -fuzz distance       colors  within  this  distance  are
       considered equal
         -interlace type      type of image interlacing scheme
         -interpolate method  pixel color interpolation method
         -limit type value    pixel cache resource limit
         -list type           Color, Configure, Delegate, Format,
       Magic, Module,
                              Resource, or Type
         -matte               store matte channel  if  the  image
       has one
         -monitor             monitor progress
         -ping                   efficiently    determine   image
 
 
 
ImageMagick         Date: 2005/03/01 01:00:00                   1
 
 
 
 
 
identify(1)                                           identify(1)
 
 
       attributes
         -quiet               suppress all warning messages
         -regard-warnings     pay attention to warning messages
         -sampling-factor geometry
                              horizontal  and  vertical  sampling
       factor
         -seed  value          seed a new sequence of pseudo-ran-
       dom numbers
         -set attribute value set an image attribute
         -size geometry       width and height of image
         -strip               strip image  of  all  profiles  and
       comments
         -units type          the units of image resolution
         -verbose              print  detailed  information about
       the image
         -virtual-pixel method
                              virtual pixel access method
 
       Miscellaneous Options:
         -debug events        display copious debugging  informa-
       tion
         -help                print program options
         -log format          format of debugging information
         -list  type            print  a list of supported option
       arguments
         -version             print version information
 
       By default, the image format of `file'  is  determined  by
       its  magic  number.  To specify a particular image format,
       precede the filename with an image format name and a colon
       (i.e.  ps:image) or specify the image type as the filename
       suffix (i.e. image.ps).  Specify 'file' as '-'  for  stan-
       dard input or output.

convert程序也是ImageMagick工具集里的一个工具。你可以用它在将图像转换为不同的格式,同时可以用它修改图像尺寸、模糊、裁切、去污点、振动、吸收以及更多的操作。请参阅 http://www.imagemagick.org/script/convert.php

类型转换
我们先看一下图像类型转换的例子, 例如我们把图像test.png转换为test.jpg

代码: 全选

# convert test.png test.jpg
我们来对比一下这两幅图
test.png和test.jpg
图片图片图片

下面的命令就在转换的同时将尺寸缩小为原图的30%:

代码: 全选

# convert test.png -resize 30% test-30.jpg
我们来对比一下这两幅图
test.png和test-30.jpg
图片图片图片

水平翻转: -flop

代码: 全选

#convert test.png -flop testflop.png
我们来对比一下这两幅图
test.png和testflop.png
图片图片图片

上下翻转:-flip

代码: 全选

#convert test.png -flip testflip.png
我们来对比一下这两幅图
test.png和testflip.png
图片图片图片

裁切:-crop

代码: 全选

# convert test.png -crop 20 testcrop.png
这会将原图按照指定的宽度裁切为几张图,我们来对比一下这几幅图
test.png和testcrop-0.png,testcrop-1.png,testcrop-2.png
图片
图片图片图片图片图片

更换彩色空间: -colorspace

代码: 全选

# convert test.png -colorspace Gray testgray.png
我们来对比一下这两幅图
test.png和testgray.png
图片图片图片


模糊:blur radius

代码: 全选

# convert test.png -blur 5 testblur.png
我们来对比一下这两幅图
test.png和testblur.png
图片图片图片

裁边: -trim

代码: 全选

# convert test.png -trim testtrim.png
我们来对比一下这两幅图
test.png和testrim.png
图片图片图片

锐化: -sharpen

代码: 全选

# convert testblur.png -sharpen 50 testsharpen.png
我们来对比一下这两幅图
testblur.png和tessharpen.png
图片图片图片

还有很多效果请大家自行查阅手册吧。
这也有一些例子
图片

总之ImageMagick系列图像处理软件的功能太强劲了,无法一一列举,请大家自行上其主页上查找,主要的工具还有
mogrify
按规定尺寸制作一个图像,模糊,裁剪,抖动等。Mogrify改写最初的图像文件然后写到一个不同的图像文件。

composite
根据一个图片或多个图片组合生成图片。

montage
创建一些分开的要素图像。在含有要素图像任意的装饰图片,如边框、结构、图片名称等。

compare
在算术上和视觉上评估不同的图片及其它的改造图片。

display
如果你拥有一个X server的系统,它可以按次序的显示图片

animate
利用X server显示动画图片

import
在X server或任何可见的窗口上输出图片文件。 你可以捕获单一窗口,整个的荧屏或任何荧屏的矩形部分。

conjure
解释执行 MSL (Magick Scripting Language) 写的脚本。

其中我原来比较常用的是import, 用来作为屏幕捕捉使用。
未完待续、请勿转载、欢迎纠错、多谢!;)
[email]WHOAMi@点点儿[/email]

回复

在线用户

正浏览此版面之用户: 没有注册用户 和 14 访客