ImageMagick is, first of all, an image-to-image converter. That is what it wasoriginally designed to do. That is, it will convert an image in just aboutany image format (tell us if it can't) to any other image format.
But it is also a library of image processing algorithms. These can beaccess via the command line and shell/DOS scripts (which these example pagesdemonstrate), or via a large number of programming languages, such as C, C++,Perl, Ruby, PHP, etc. See: ImageMagick APIs.
Speed was never a major feature of IM, which places more emphasis on thequality of the images it generates. That is not to say that it can'ttransform images in a reasonable amount of time. It's just not blindinglyfast. Because of this, IM can be slow to perform certain processingoperations, especially when attempting to compress images into image formatsthat have limited capabilities.
ImageMagick concerns itself mainly with images in the form of a rectangulararray of pixels, commonly called a "raster." It will handle "vector"image formats like Postscript or PDF, but at the cost of converting thoseimages into a raster when loading them, and generating a vector image wrapperaround the raster when saving it. As a result, vector images are oftenprocessed badly when using the default settings. However, specific optionscan be used to improve this situation. See: A word about vector image formats.
Other examples were grabbed or developed from answers to users' questions onhe IMForums, or contributed to me as solutions to various problems.
I look forward to suggestions and e-mail from other IM users. Such e-mailgenerally results in improvements and expansions to these example pages.
\
' at the end of a line tocontinue that command on the next line. The longer commands are broken intoseparate lines to try to further highlight the steps being applied. However, you can still use these examples from PC Windows batchscripts, with some changes to the handling of certain characters. Withsome slight adaptation, the examples can also be run directly from'system
' calls in PHP scripts.
See Windows Usage and APIsand Scripting for more information on using the ImageMagick commands inthese alternative environments. Contributions and test examples are welcome.
Although the situation has improved enormously with IM version 6, the commandline really only deals with a single image sequence at any one time. However,APIs do not have this limitation, and allow you to manipulate multiple imagesequences, separately or together, to perform more complex operations. Thisability makes it simpler to implement these examples using the IM API, andremoves the need to save images as temporary files, as many of the commandline examples require. When using an API, only permanent and semi-permanentimages need be saved to disk.
Basically, let the example pages give you a start, to let you see whatis possible with ImageMagick. Then, formulate what you want to do onthe command line, before coding the operations in scripts and APIcode, where it is harder to make extensive changes.
I also recommend that you comment your API code, heavily, adding thecommand line equivalents to what you are trying to do, if possible. That way,you can check and compare the results against those using the command line.This lets you debug problems that you may come across later, especially asimprovements are made to image processing in the Core ImageMagick Library.
logo:
" or "rose:
") as input images for IM examplecommands, or to generate input images using IM commands. I also often re-usethe output of previous commands in later examples. Because of this, youusually don't need to download any 'test' images in order to try out theexamples yourself. However, such generated or built-in images are not always convenient. So,when I do use an external image, I tend to re-use that input image, or theresults of previous examples, for later examples in that section.
Sometimes the original source image will be displayed or for larger imagesa link to the source image is provided. More commonly only the final resultingimage will be shown, as the input is well known or obvious.
Almost all the IM example commands shown are executed in the same webdirectory in which they appear. That is, the command you see is the commandthat was actually used to generate the image. Because of this you can modifythe page's URL to download or view the input image(s) used by an example.Extra copies of the external source images have also been placed in the "images" and "img_photos"sub-directories. See also the example of a Fancy Photo Index of those images.
If text output or image information is produced by an example, it is saved toa text file, and an image of it is generated for display on the Web page.Selecting the text output image will link you to a copy of the actual textoutput by the command.
In all these examples, selecting the output image should let you download theimage which was actually created by the example command. But be warned, notall browsers understand all image formats used.
This library actually predates the WWW. I created it in 1991, due to the lackof good, clean iconic images for use on the X Window System. The advent ofthe WWW has of course changed this, but my original library still exists andremains available as a source of images, even though it is not activelygrowing.
Some specific images, and larger images, are contributed by the authors ofspecific examples. The authors of such examples are listed in the contributedsection, or at the bottom of the page.
If you are looking for a specific image, I recommend using Google Image Search (or similar) tofind something appropriate. You can, of course, convert or resize such imagesusing IM for your own purposes. However, you should be careful aboutcopyright if you plan to use such images commercially.
Some Web browsers, however, do NOT handle transparent PNG images correctly(most notably Microsoft Internet Explorer v6). Because of this, I generallyuse the JPEG and GIF formats for images on the Web, and only use the PNGformat when generating images with semi-transparent pixels, or when exactcolors are needed for later examples.
To allow IE v6 browsers to display PNG images, I use a special 'style sheet'using complex JavaScript. For information on this, see PNG withtransparency for IE. Technically, this is only problem with IE, notImageMagick.
The image displayed in the above example is a special PNG-format test image, which was generated using the shellscript "generate_test
".Normally, the command would output the results to your display, not onto a Webpage like this.
If you look carefully, you can see the checkerboard pattern though thesemi-transparent colors. However, the image, as a whole, is fully opaque. So,this technique should work on all displays, Web browsers, and image viewers.
As of IM v6.0.2, the "display
" program performs something likethis automatically. However, it does not seem to handle images using colortables (i.e., GIF) in this way. Using the "x:
" output image format(as above) causes an image to be displayed directly to the screen, withouthaving to save it. See Show Output Display for moreinformation.
You are, however, welcome to substitute other fonts that you have available.The examples should work (perhaps with some changes to image size) with anyappropriate font you have available on your system. Microsoft "Arial" font, oreven "Times-BoldItalic", should work on most systems.
To see what fonts are currently available to your version of IM, run thefollowing command...
|
WARNING: If the font requested is not found, ImageMagick used to silentlysubstitute a default font, typically Arial or Times. It still does this, but awarning is now given. So, test the font beforehand, to make sure that it isthe one you want, and not the default font.
On my Linux system, I use a special Perl script, "imagick_type_gen
", togenerate a file, "type.xml
", saved in the ".magick
"sub-directory of my home directory. ImageMagick uses that file, which containsa font list in XML format, to find fonts. The script "locate
"s(run "updatedb
" first, if you have just added new fonts), anddescribes all the fonts available on my system. With this setup, I only needto specify the name of the font I want to use, and not the full path to aspecific font file.
For example...
|
Before IM v6.1.2-3, the "type.xml " file was named "type.mgk ". If you are using an earlier version of IM. |
The fonts used in these IM examples are listed in a Montage of Example Fonts Example. Mypersonal favorite is Candice, so it gets used quite a bit.
If you also like the 'Candice ' font, or any of the other fonts I use, grab them from Free Fonts or 1001 Fonts .com. |
Often these examples are re-built using the latest beta release of IM, allowingme to see changes and bugs that may appear in each version of IM, before it isgenerally released. However, the example images shown are what the given IMcommand produces on my system. If you get something different, your IMis probably a much older version (with old bugs), or is not correctlyinstalled.
Note that e-mailing me, or discussing some aspect of ImageMagick on the IM Mailing List,or IM Users Forum will generally result innew examples, or whole new sections, being added to these examples. The morediscussion there is, the better the examples become.
If you are doing anything interesting with IM, please share, and allow me toprovide examples of your technique to the rest of the IM community. Some of thebiggest advances in IM usage have come from users just like you.
He has done a marvelous job making Version 6 the best and most advanced commandline image processing program available. While most users will not showappreciation for that, I certainly do appreciate the effort he has put into IM.
I also want to thank Gabe Schaffer, who has been most helpful in discussionsinvolving the JPEG format and library, affine matrix operators, and MagickVector Graphics in general.
And to Glenn Randers-Pehrson, who looks after the PNG coder module and has ainterest in Color Quantization and Dithering. He was the first to add'halftone' dithering to IM, which I later revised and extended further, toadded new dithers to the ordered dither configuration file.
And finally, I want to thank the huge number of people with problems,suggestions, and solutions, who generally lurk on the IM User Forum. Many now have their names ascontributors of ideas and suggestions throughout IM Examples.
I also want to thank the people who regularly answer questions on the forums,such as 'Bonzo', and his web site RubbleWebs, detailing useof IM commands from PHP scripts. Also 'scri8e' and his Web site, MoonsStars, for glitter and star handling. Also a thank you goes to Pete 'el_supremo' (see his MagickWandC-Programming), and the many others who regularly answer other peoples'questions.
A special thanks goes to Fred Weinhaus, a researcher from the early days of image processing, whowas a major help in the initial implementation of the General Image Distortion Operator. You can seeFred's ImageMagick scripts on Fred's ImageMagick Site, often as a proof of concept for future IMadditions.
Also to Nicolas Robidoux, an expert in digital image processing, for reworkingthe Elliptical Weighted AverageResampling, which vastly improves the output of General Image Distortion.
And finally to the many users of ImageMagick who, had allowed others to seethe IM commands they use as part of some project, either on the forums, or onthe web. You are all to be commended on your willingness and openness to shareyour findings.
Well enough "Yadda, yadda, yadda." Go look at some of the examples.
联系客服