ImageMagick学习
时间:2006-12-25 来源:tystok
ImageMagick学习
ImageMagick是 一套稳定的工具集和开发包,可以用来读、写和处理超过89种基本格式的图片文件,包括流行的TIFF, JPEG, GIF, PNG, PDF以及PhotoCD等格式。利用ImageMagick,你可以根据web应用程序的需要动态生成图片, 还可以对一个图片或图片序列进行改变大小、旋转、锐化、减色或增加特效,并将操作的结果以相同格式或其它格式保存。对图片的操作,可以通过命令行进行,也 可以用C/C++、Perl、Java、PHP、Python或Ruby编程来完成。同时ImageMagick提供了一个高质量的2D工具包,部分地支 持SVG。现在,ImageMagic的主要精力集中在性能、减少bug以及提供稳定的API和ABI上。
ImageMagick功能强大,却免费的。
ImageMagick的功能
包括:- 将图片从一个格式转换到另一个格式
- 改变尺寸、旋转、锐化(sharpen)、减色、图片特效
- 缩略图片的合成图( a montage of image thumbnails)
- 适于web的背景透明的图片
- 将一组图片做成gif动画
- 将几张图片做成一张组合图片
- 在一个图片上写字或画图形
- 给图片加边框或框架
- 取得一些图片的特性信息
右面是一些例子。
ImageMagick几乎可以在任何非专有的操作系统上编译,无论是32位还是64位的CPU,包括*nix ,Windows '95/'98/ME/NT 4.0/2000/XP, Macintosh (MacOS 9 /10), VMS 和 OS/2.
下载安装
ImageMagick在很多服务器上都可以下到,甚至很多个人站点也提供了下载。建议到ImageMagick的官方主页上下载最新版本的源码包,我下的是ImageMagick-5.5.6.tar.gz,在linux下的安装过程如下: tar zxvf ImageMagick-5.5.6.tar.gzcd ImageMagick-5.5.6
./configure
make all
su
make install
注意不要忘记,将ImageMagick安装后的函数库所在目录加入到/etc/profile文件中的LD_LIBRARY_PATH环境变量中,以及/etc/ld.so.conf中同时运行ldconfig,否则一些对ImageMagic的应用可能会出问题。
使用说明
程序名 | 命令行参数 | 说明 |
animate | [ options ... ] file [ [ options ... ] file ... ] | 显示一个图片序列。为防止颜色闪烁,它会费时为图片序列创建一个颜色表,这可通过减色来加快速度,参见 http://www.wizards.dupont.com/cristy/www/animate.html。 |
composite | [ options ... ] image composite [ mask ] composited | 将图片合成为新图片。 |
conjure | [ options ] script.msl [ [ options ] script.msl ] | 解释并执行Magick Scripting Language (MSL).语言脚本。 |
convert | [ [ options ... ] [ input_file ... ] ... [ output_file ] ] | 转换图片的大小、格式等。 |
display | [ options ... ] file ... [ [options ... ]file ... ] | 一个独立于机器框架的图片处理和显示程序,能在任何运行X服务器的工作站上显示图片。 |
identify | file [ file ... ] | 描述一张或一些图片的格式或个性信息,如果图片不完整或被破坏也会有相应报告。 |
import | [ options ... ] file | 读取X服务器上任何可见窗口中的图象将输出为图片文件。可以用它抓取一个窗口、整个屏幕或屏幕上的任何矩形区域。 |
mogrify | [ options ... ] file ... | 转换一张图片或一个图片序列. 包括图片缩放、旋转、减色及其它操作。转换结果覆盖原图片。 |
http://www.imagemagick.org/www/utilities.html 有对命令行参数的详细说明,http: //www-106.ibm.com/developerworks/library/l-graf/?ca=dnt-428有一些使用例程。http: //www.starlink.rl.ac.uk/star/docs/sc15.htx/node57.html有一些说明。
ImageMagick还支持一种平台无关的文件格式Magick Image File Format (MIFF)格式,用来保存bitmap图片.ImageMagick能将MIFF与JPEG, XPM, TIFF等多种格式的图片互相转换。
附:ImageMagick支持图片格式、内建图片和图片模板以及嵌入图片模板。
Supported ImageFormats
Format |
Mode |
Description |
Notes |
---|---|---|---|
ART | R | PFS:1st Publisher | Formatoriginally used on the Macintosh (MacPaint?) and later used forPFS: 1st Publisher clip art. |
AVI |
R | MicrosoftAudio/Visual Interleaved |
|
AVS | RW | AVS Ximage |
|
BMP |
RW | MicrosoftWindows bitmap |
|
CGM | R | ComputerGraphics Metafile | Requiresralcgm torender CGM files. |
CIN |
RW | KodakCineon Image Format |
Cineon Image Format is a subset of SMTPE DPX. |
CMYK | RW | Rawcyan, magenta, yellow, and black samples | Set-size and-depth to specify theimage width, height, and depth. |
CUR | R | MicrosoftCursor Icon |
|
CUT | R | DR Halo |
|
DCM | R | DigitalImaging and Communications in Medicine (DICOM) image | Usedby the medical community for images like X-rays. |
DCX | RW | ZSoftIBM PC multi-page Paintbrush image |
|
DIB | RW | MicrosoftWindows Device Independent Bitmap | DIB is aBMP file without theBMP header. Used to support embedded images incompound formats like WMF. |
DPX | RW | DigitalMoving Picture Exchange |
|
EMF | R | MicrosoftEnhanced Metafile (32-bit) | Onlyavailable under Microsoft Windows. |
EPDF | RW | EncapsulatedPortable Document Format |
|
EPI | RW | AdobeEncapsulated PostScript Interchange format | RequiresGhostscriptto read. |
EPS | RW | AdobeEncapsulated PostScript | RequiresGhostscriptto read. |
EPS2 | W | AdobeLevel II Encapsulated PostScript | RequiresGhostscriptto read. |
EPS3 | W | AdobeLevel III Encapsulated PostScript | RequiresGhostscriptto read. |
EPSF | RW | AdobeEncapsulated PostScript | RequiresGhostscriptto read. |
EPSI | RW | AdobeEncapsulated PostScript Interchange format | RequiresGhostscriptto read. |
EPT | RW | Adobe Encapsulated PostScript Interchange format withTIFF preview | RequiresGhostscriptto read. |
FAX | RW | Group3 TIFF | SeeTIFF format. Note that FAXmachines use non-square pixels which are 1.5 times wider than theyare tall but computer displays use square pixels so FAX images mayappear to be narrow unless they are explicitly resized using aresize specification of "150x100%". |
FIG |
R | FIGgraphics format | RequiresTransFig. |
FITS |
RW | FlexibleImage Transport System |
|
FPX | RW | FlashPixFormat | RequiresFlashPixSDK. |
GIF | RW | CompuServeGraphics Interchange Format | 8-bitRGB PseudoColor with up to 256 palette entires. Specify theformat "GIF87" to write the older version 87a of the format.Note that since Unisys claims apatent onthe LZW algorithm (expiring world-wide as of June 2004) used byGIF, ImageMagick binary distributions do not include support forthe LZW algorithm so GIF files are written uncompressed. Users arerecommended to use the PNG or JPEG formats instead, and shouldconsult theUnisysLZW web page before enabling LZW support. |
GPLT | R | Gnuplotplot files | Requiresgnuplot3.5.tar.Zor later. |
GRAY | RW | Rawgray samples | Use-size and-depth to specify theimage width, height, and depth. |
HPGL | R | HP-GLplotter language | Requireshp2xx-3.2.0.tar.gz |
HTML | RW | HypertextMarkup Language with a client-side image map | Also known as "HTM". Requireshtml2ps to read. |
ICO | R | Microsofticon | Alsoknown as "ICON". |
JBIG | RW | JointBi-level Image experts Group file interchange format | Also known as "BIE" and "JBG". Requiresjbigkit-1.0.tar.gz. |
JNG |
RW | Multiple-imageNetwork Graphics | JPEG in a PNG-style wrapper with transparency. Requireslibjpeg and libpng-1.0.2 or later,libpng-1.2.5or later recommended. |
JP2 | RW | JPEG-2000JP2 File Format Syntax | Requiresjasper-1.600.0.zip |
JPC | RW | JPEG-2000Code Stream Syntax | Requiresjasper-1.600.0.zip |
JPEG | RW | JointPhotographic Experts Group JFIF format | Requiresjpegsrc.v6b.tar.gz |
MAN | R | Unixreference manual pages | Requiresthat GNU groff and Ghostcript are installed. |
MAT | R | MATLABimage format |
|
MIFF |
RW | Magickimage file format | OpenImageMagick's own image format (with ASCII header) which ensuresthat no image attributes understood by ImageMagick are lost. |
MONO | RW | Bi-levelbitmap in least-significant-byte first order |
|
MNG |
RW | JPEGNetwork Graphics | Requires libpng-1.0.2 or later,libpng-1.2.5or later recommended. |
MPEG |
RW | MotionPicture Experts Group file interchange format (version 1) | Requiresmpeg2vidcodec_v12.tar.gz. |
M2V |
RW | MotionPicture Experts Group file interchange format (version 2) | Requiresmpeg2vidcodec_v12.tar.gz. |
MPC | RW | MagickPersistent Cache image file format | Thenative "in-memory" ImageMagick uncompressed file format. Thisfile format is identical to that used by Open ImageMagick torepresent images in memory and is read in "zero time" via memorymapping. The MPC format is not portable and is not suitable as anarchive format. It is suitable as an intermediate format forhigh-performance image processing.TheMPC format requires two files to support one image. When writingthe MPC format, a file with extension ".mpc" is used to storeinformation about the image, while a file with extension “.cache”stores the image pixels. The storage space required by a MPC image(or an image in memory) may be calculated by the equation(QuantumDepth*Rows*Columns*5)/8. |
MSL | RW | MagickScripting Language | MSL is the XML-based scripting language supported by the conjure utility. |
MTV | RW | MTVRaytracing image format |
|
MVG | RW | MagickVector Graphics. | The native ImageMagick vector metafile format. A textfile containing vector drawing commands accepted by convert's -draw option. |
OTB | RW | On-the-airBitmap |
|
P7 | RW | Xv'sVisual Schnauzer thumbnail format |
|
PALM | RW | Palmpixmap |
|
PBM | RW | Portablebitmap format (black and white) |
|
PCD | RW | PhotoCD | Themaximum resolution written is 768x512 pixels since larger imagesrequire huffman compression (which is not supported). |
PCDS | RW | PhotoCD | Decodewith the sRGB color tables. |
PCL | W | HPPage Control Language | Foroutput to HP laser printers. |
PCX | RW | ZSoftIBM PC Paintbrush file |
|
PDB | RW | PalmDatabase ImageViewer Format |
|
RW | PortableDocument Format | RequiresGhostscriptto read. | |
PFA | R | PostscriptType 1 font (ASCII) | Openingas file returns a preview image. |
PFB | R | PostscriptType 1 font (binary) | Openingas file returns a preview image. |
PGM | RW | Portablegraymap format (gray scale) |
|
PICON | RW | PersonalIcon |
|
PICT | RW | AppleMacintosh QuickDraw/PICT file |
|
PIX | R | Alias/WavefrontRLE image format |
|
PNG |
RW | PortableNetwork Graphics | Requires libpng-1.0.2 or later,libpng-1.2.5or later recommended. |
PNM | RW | Portableanymap | PNM isa family of formats supporting portable bitmaps (PBM) , graymaps(PGM), and pixmaps (PPM). There is no file format associated withpnm itself. If PNM is used as the output format specifier, thenImageMagick automatically selects the most appropriate format torepresent the image.The default is to write the binary version of theformats. Use+compress to write the ASCII version of theformats. |
PPM | RW | Portablepixmap format (color) |
|
PS | RW | AdobePostScript file | RequiresGhostscriptto read. |
PS2 | RW | AdobeLevel II PostScript file | RequiresGhostscriptto read. |
PS3 | RW | AdobeLevel III PostScript file | RequiresGhostscriptto read. |
PSD | RW | AdobePhotoshop bitmap file |
|
PTIF | RW | Pyramid encodedTIFF | Multi-resolutionTIFF containingsuccessively smaller versions of the image down to the size of anicon. The desired sub-image size may be specified when reading viathe -size option. |
PWP |
R | SeattleFile Works multi-image file |
|
RAD | R | Radianceimage file | Requiresthatra_ppm from the Radiance software package beinstalled. |
RGB | RW | Rawred, green, and blue samples | Use-size and-depth to specify theimage width, height, and depth. |
RGBA | RW | Rawred, green, blue, and matte samples | Use-size and-depth to specify theimage width, height, and depth. |
RLA | R | Alias/Wavefrontimage file |
|
RLE | R | UtahRun length encoded image file |
|
SCT |
R | ScitexContinuous Tone Picture |
|
SFW |
R | SeattleFile Works image |
|
SGI | RW | IrixRGB image |
|
SHTML | W | HypertextMarkup Language client-side image map | Used to write HTML clickable image maps based on a theoutput of montage or a format whichsupports tiled images such as MIFF. |
SUN | RW | SUNRasterfile |
|
SVG |
RW | ScalableVector Graphics | Requireslibxml2 andfreetype-2. Note that SVG is avery complex specification so support is still not complete. |
TGA | RW | TruevisionTarga image | Alsoknown as formats "ICB", "VDA", and "VST". |
TIFF | RW | TaggedImage File Format | Also known as "TIF". Requirestiff-v3.5.4.tar.gzor later. Note that since Unisys claims apatent onthe LZW algorithm (expiring in the US as of June 2003) used byLZW-compressed TIFF files, ImageMagick binary distributions do notinclude support for the LZW algorithm so LZW TIFF files can not bewritten. Although a patch is available for libtiff to enablebuilding with LZW support. Users should consult theUnisys LZW web pagebefore applying it. |
TIM | R | PSXTIM file |
|
TTF |
R | TrueTypefont file | Requiresfreetype 2.Opening as file returns a preview image. |
TXT | RW | Rawtext file |
|
UIL | W | X-MotifUIL table |
|
UYVY | RW | InterleavedYUV raw image | Use-size command line option to specify widthand height. |
VICAR | RW | VICARrasterfile format |
|
VIFF | RW | KhorosVisualization Image File Format |
|
WBMP |
RW | Wirelessbitmap | Supportfor uncompressed monochrome only. |
WMF |
|
WindowsMetafile | Requireslibwmf.By default, renders WMF files using the dimensions specified by themetafile header. Use the -density option to adjust the outputresolution, and thereby adjust the ouput size. The default outputresolution is 72DPI so "-density 144" results in an image twiceas large as the default. Use-background color tospecify the WMF background color (default white) or-texturefilename to specify a background texture image. |
WPG | R | WordPerfect Graphics File |
|
XBM | RW | XWindows system bitmap, black and white only | Usedby the X Windows System to store monochrome icons. |
XCF | R | GIMPimage |
|
XPM |
RW | XWindows system pixmap | Alsoknown as "PM". Used by the X Windows System to store color icons. |
XWD | RW | XWindows system window dump | Usedby the X Windows System to save/display screen dumps. |
YUV | RW | CCIR601 4:1:1 | Use-size command line option to specify widthand height. |
Pseudo ImageFormats
Tag | Mode | Description | Notes |
---|---|---|---|
CAPTION |
R | Imagecaption | fixme |
CLIPBOARD | RW | WindowsClipboard | Onlyavailable under Microsoft Windows. |
FRACTAL | R | Plasmafractal image |
|
GRADIENT | R | Gradualpassing from one shade to another | Returns a rendered gradient image using the specifiedimage size. Specify the desired shading as part of the filename(e.g. "gradient:red-blue"or "gradient:#F00-#00F"). |
HISTOGRAM | W | Histogramof the image |
|
LABEL | R | Textimage format | Specify the desired text as the filename (e.g. "label:Thisis a label"). |
MAP | RW | Colormapintensities and indices | Set-depth to set the sample size of the intensities; indices are16-bit if colors > 256. |
MATTE | W | MATTEformat | Writeonly. |
NULL | RW | NULLimage | Useful for creating blank tiles with montage (use "NULL:"). Also useful as anoutput format when evaluating image read performance. |
PLASMA | R | Plasmafractal image |
|
PREVIEW | W | Show apreview an image enhancement, effect, or f/x | Creates a preview montage of images prepared over aparameteric range in order to assist with parameter selection.Specify the desired preview type via the -preview option). |
W | Sendimage to your computer printer | Unixusers may set the PRINTER (for 'lp') or LPDEST (for 'lpr')environment variables to select the desired printer. | |
SCAN | R | Importimage from a scanner device | Requires SANESpecify the device name and path as the filename (e.g. "scan:mustek:/dev/scanner"). |
STEGANO | R | Steganographicimage | Use -size command line option to specify width,height, and offset of the steganographic image |
TILE | R | Tiledimage | Createa tiled version of an image at by tiling a image. Use -size tospecify the tiled image size. The image is specified similar to "TILE:image.miff". |
VID | RW | VisualImage Directory | Used to create a thumbnailed directory (tiled thumbnails)of a set of images which may be used to select images to view viathe display program, or saved to a MIFF or SHTML file. |
WIN | RW | Selectimage from or display image to your computer screen | Onlysupported under Microsoft Windows. |
X | RW | Selectimage from or display image to your X server screen | Also see the import and display programs. |
XC | R | Canvasimage of specified color | Useful to create solid color "canvas" images. Use -sizeand -depth to specify the image width, height, anddepth. Example XC color specifications include "XC:red" and "XC:#FF0000". |
Built-in Image Formats
Name | Description | Notes/Sample |
---|---|---|
GRANITE | 128x128granite texture pattern | |
LOGO | 640x480,ImageMagick Logo | |
NETSCAPE | 216x144image using colors in Netscape 216 (6x6x6 ) color cube. |
Most commonly used with the convert/mogrify -map option to create “web safe”images. |
ROSE | 70x46,Picture of a rose. |
Built-inImage Patterns
Name | Description | Notes/Sample |
---|---|---|
BRICKS | 16x16brick pattern | |
CHECKERBOARD | 30x30checkerboard pattern | |
CIRCLES | 16x16circles pattern | |
CROSSHATCH | 8x4crosshatch pattern | |
CROSSHATCH30 | 8x4crosshatch pattern with lines at 30 degrees. | |
CROSSHATCH45 | 8x4crosshatch pattern with lines at 45 degrees. | |
FISHSCALES | 16x8fish scales pattern | |
GRAY0 | 32x320% intensity gray | |
GRAY5 | 32x325% intensity gray | |
GRAY10 | 32x3210% intensity gray | |
GRAY15 | 32x3215% intensity gray | |
GRAY20 | 32x3220% intensity gray | |
GRAY25 | 32x3225% intensity gray | |
GRAY30 | 32x3230% intensity gray | |
GRAY35 | 32x3235% intensity gray | |
GRAY40 | 32x3240% intensity gray | |
GRAY45 | 32x3245% intensity gray | |
GRAY50 | 32x3250% intensity gray | |
GRAY55 | 32x3255% intensity gray | |
GRAY60 | 32x3260% intensity gray | |
GRAY65 | 32x3265% intensity gray | |
GRAY70 | 32x3270% intensity gray | |
GRAY75 | 32x3275% intensity gray | |
GRAY80 | 32x3280% intensity gray | |
GRAY85 | 32x3285% intensity gray | |
GRAY90 | 32x3290% intensity gray | |
GRAY95 | 32x3295% intensity gray | |
GRAY100 | 32x32100% intensity gray | |
HEXAGONS | 30x18hexagon pattern | |
HORIZONTAL | 8x4horizontal line pattern | |
HORIZONTALSAW | 16x8horizontal saw-tooth pattern | |
HS_BDIAGONAL | 8x8backward diagonal line pattern (45 degrees slope) | |
HS_CROSS | 8x8cross line pattern | |
HS_DIAGCROSS | 8x8diagonal line cross pattern (45 degrees slope) | |
HS_FDIAGONAL | 8x8forward diagonal line pattern (45 degrees slope) | |
HS_HORIZONTAL | 8x8horizontal line pattern | |
HS_VERTICAL | 8x8vertical line pattern | |
LEFT30 | 8x4forward diagonal pattern (30 degrees slope) | |
LEFT45 | 8x8forward diagonal line pattern (45 degrees slope) | |
LEFTSHINGLE | 24x24left shingle pattern | |
OCTAGONS | 16x16octagons pattern |
|
RIGHT30 | 8x4backward diagonal line pattern (30 degrees) |
|
RIGHT45 | 8x8backward diagonal line pattern (30 degrees) |
|
RIGHTSHINGLE | 24x24right shingle pattern |
|
SMALLFISHSCALES | 8x8small fish scales pattern | |
VERTICAL | 8x8vertical line pattern | |
VERTICALBRICKS | 16x16vertical brick pattern | |
VERTICALLEFTSHINGLE | 24x24vertical left shingle pattern | |
VERTICALRIGHTSHINGLE | 24x24vertical right shingle pattern | |
VERTICALSAW | 8x16vertical saw-tooth pattern |
Format | Mode | Description | Notes |
---|---|---|---|
8BIM | RW | Photoshopresource format (binary) |
|
8BIMTEXT | RW | Photoshopresource format (ASCII) | AnASCII representation of the 8BIM format. |
APP1 | RW | Rawapplication information |
|
APP1JPEG | RW | RawJPEG binary data | Profilein JPEG wrapper. |
ICC | RW | InternationalColor Consortium color profile |
Also known as "ICM". To read, use -profile withconvert. |
IPTC | RW | IPTCNewsphoto (binary) |
To read, use -profile with convert |
IPTCTEXT | RW | IPTCNewsphoto (ASCII) | AnASCII representation of the IPTC format. |
FAQ
4. 如何让animate在显示图片的过程保持窗口的标题不变?
animate -title "My Image Sequence" images.
5. import抓得的图片与X服务器上显示的不一致怎么办?
import -descend image.miff
6. 如何动画显示YUV 图片序列?
animate -geometry 352x240 -scene 0-71 yuv3:frame%d
7. 如果只看一个RGB图片的红色通道(red channel)?
display -gamma 1.0,0.0,0.0 image.miff
8. 如何改变PostScript默认纸张大小?
要改变默认的612x792大小,修改magick/image.h中的PSPageGeometry的值并重编译.
10. 如何自左至右无边无框无文字半三幅画连接在一起?
convert +append image1.ppm image2.ppm image3.ppm side_by_side.miff
或
convert -size 350x500 xc:black composite.miff
composite -geometry +0+0 composite.miff image1.gif composite.miff
composite -geometry +100+0 composite.miff image2.gif composite.miff
composite -geometry +0+300 composite.miff image3.gif composite.miff
composite -geometry +0+375 composite.miff image4.gif composite.miff
11. 如何生成gif动画?
convert -delay 20 frame*.gif animation.gif
convert -delay 20 frame1.gif -delay 10 frame2.gif -delay 5 frame3.gif animation.gif
convert frame1.gif -page +50+100 frame2.gif -page +0+100 frame3.gif animation.gif
convert -loop 50 frame*.gif animation.gif
convert +adjoin images.* frames%d.gif
12. 如果完整的显示PostScript图片?
display -page letter image.ps
13. 什么是图片目录?如何使用它们?
图片目录(visual image directory ,VID)的创建:
montage *.jpg directory.vid
convert 'vid:*.jpg' directory.vid
显示图片目录
display directory.vid
display vid:movie.mpg
15. 如果带框架保存一个窗口?
xwininfo -frame
import -frame -window ID window.miff
16. 图片以单一颜色(a solid color)显示,是怎么回事?
图片被破坏,或含有值为0的matte层,试着:
display +matte image.miff
17. 出现 "???? library is not available ..."是怎么回事?
没安装相关的函数库。参见安装说明。
18. 如何查看图片不光滑层(matte channel)的值?
convert image.tiff image.matte
display -size 640x480 gray:image.matte
19. 运行"Convert in.gif out.png" 时显示 "Invalid Parameter - out.png"
你运行的convert是windows的分区类型转换程序。
20. 如何在图片增加斜角?
对图片边缘的处理共分四类。
1)增加有色边
convert -bordercolor red -border 25x25 image.jpg image.gif
2)加亮或变暗图片边缘,以增强3D效果
convert -raise 25 image.jpg image.gif
3)在图片周围增加装饰性框架。
convert -mattecolor gray -frame 25x25 image.jpg image.gif
4)在图片边缘增加升、降斜角
convert -mattecolor gray -frame 25x25+0+25 image.jpg image.gif
convert -mattecolor gray -frame 25x25+25+0 image.jpg image.gif
21. 用窗口管理器运行display失败了,怎么办?
用下列命令之一来确认display运行在一个交互环境中:
display logo:Untitled
display < /dev/console
22. 将PostScript文件转换为其它格式时,如何改善文字的外观?
convert -density 288 -geometry 25% image.ps image.gif
23. 如何用2-3英寸高的文字注释一个图片?
先检查有无可缩放字体:
xlsfonts -fn '*-0-0-0-0-*'
有则:
convert -font '-*-helvetica-*-*-*--300-300-*-*-*-*-iso8859-1' -fill green -draw 'text 50,300 Magick' image.gif annotated.gif
If you have the FreeType support built into ImageMagick, just increase your pointsize and/or density:
convert -font Helvetica -pointsize 100 -density 300 ...
24. 如何将gif文件分析为一系列的单个图片?
convert animation.gif frame%02d.gif
25. 用NetScape显示的图片,如何去掉周围的背景色?
对convert用+page参数:
convert +page alpha.gif beta.gif
26. 如何用web安全的颜色(Web safe colors)创建GIF或PNG图片?
对convert用 -map 参数:
convert -map netscape: alpha.gif beta.gif
27. 为何Adobe Acrobat 2.1不能读ImageMagick's制作的PDF?
用 Acrobat 3.0或以上版本,来阅读这种经zip压缩的pdf,或制作PDF时不进行压缩。
convert +compress images.tiff image.pdf
28. 如何在图片上增加一个不光滑层(matte channel)?
convert image.gif -matte temp.miff
composite -compose CopyOpacity mask.xbm temp.miff transparent.gif
29. 在NT环境下如何用convert在图片上写字?
convert -font Arial -fill blue -draw "text 10,10 'your text here'" d:\test.tif png:d:\test.png
convert.exe -pointsize 18 -draw "text 0,0 "This is my text!"" C:\blank.gif c:\text.gif
30. 为何GIF文件比期望的大?
需要在编译源码时加 --enable-lzw 参数,来打开LZW压缩功能。
31. 为何JPEG文件比期望的大?
可能嵌入Exif或IPTC等"profiles", 或者含有没压缩的thumbnails. 可以用命令行参数 +profile "*"或相关的API来将它们去掉。
32. 如何从图片文件中抽取第一张图片?
convert "Image.gif[0]" first.gif
convert -size 800x600 xc:"#ddddff" ltblue.ppm
convert -size 800x600 null:white white.ppm
convert in.png -threshold 100% black.ppm <--与in.png同大小
//以下来源于:http://www.5ilinux.com/blog/archives/000104.html
php+ImageMagick+imagick API Howto
php+ImageMagick+imagick API 配置指南
先去下载相关的软件:
ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-5.5.7-15.tar.gz
imagick:A native PHP-extension to ImageMagick
wget http://pecl.php.net/get/imagick-0.9.8.tgz
怎么你不知道ImageMagick是什么,不妨到这里看看ImageMagick的魅力
使用 ImageMagick 进行翻转、缩放大小、旋转以及更多操作
ImageMagick学习
怎么样ImageMagick比GD还强大吧,那好我们就来安装它。
我们今天要讲的就是直接使php支持ImageMagick,而不是用ImageMagick的命令行来进行图形转换。
tar ImageMagick-5.5.7-15.tar.gzcd ImageMagick-5.5.7
./configure \
LDFLAGS="-L/usr/lib" CPPFLAGS="-I/usr/include" \
--prefix=/usr/local/ImageMagick \
--enable-shared \
--enable-lzw
make
make install
更多参数大家看编译帮助。
对了,忘了跟大家说,最好不要用redhat自带的ImageMagick-devel包,还是自己编译的好,否则你在编译php的时候会被搞死,我可是说在前头了,出了问题不要怪我没说哦:)
要加入ImageMagick针对php的API。那么我们需要两次编译php,php第一次编译后,会产生我们编译API所需的phpize这个程序。第一次编译不讲了,跟后面第二次编译基本差不多。
在php的源代码目录
2。然后把imagick-0.9.8.tgz解压到ext/ imagick目录下
3。运行命令phpize
4。cd php源代码根目录
5。rm configure
6。./buildconf --force #好像不加--force不让重新产生configure文件
下面就是php的第二次编译
./configure --prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-imagick=/usr/local/ImageMagick
--with-apxs=/usr/local/apache/bin/apxs
make
make install
至于php的其他参数大家适当添加就行。
好了写个php的测试程序
<?php
phpinfo();
?>
恭喜你,安装成功了,去享受ImageMagick的巨大功能