File: api.html

package info (click to toggle)
imagemagick 6%3A6.0.6.2-2.9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 33,284 kB
  • ctags: 14,844
  • sloc: ansic: 190,790; cpp: 17,203; sh: 8,740; perl: 4,190; makefile: 1,740; tcl: 459
file content (309 lines) | stat: -rw-r--r-- 14,326 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<title>ImageMagick - C Application Programming Interface</title>
<meta name="Description"
content="ImageMagick is a robust collection of tools and libraries to read, write, and manipulate an image in many image formats including popular formats like TIFF, JPEG, PNG, PDF, PhotoCD, and GIF. With ImageMagick you can create images dynamically, making it suitable for Web applications. You can also resize, rotate, sharpen, color reduce, or add special effects to an image or image sequence and save your completed work in the same or differing image format. Image processing operations are available from the command line, as well as through C, C++, Perl, or Java programming interfaces." />
<meta name="Keywords"
content="ImageMagick,PerlMagick,Magick++,Image,Magick,Magic,Pixel,Graphics,Perl,Wand" />
<meta name="Resource-type" content="document" />
<meta name="Robots" content="ALL" />
<link rel="stylesheet" type="text/css" href="../www/magick.css" />
</head>
<body marginheight="1" marginwidth="1" topmargin="1"
leftmargin="1">
<a name="top" id="top"></a> 
<table border="0" cellpadding="0" cellspacing="0" summary="Masthead" width="100%">
<tbody>
<tr>
<td bgcolor="#003399" width="25%" height="118" background="../images/background.gif"><a href="http://www.imagemagick.org/"><img src="../images/script.gif" width="278" height="118" border="0" alt="" /></a></td>
<td bgcolor="#003399" width="60%" height="118" background="../images/background.gif"><a href="http://www.networkeleven.com/direct.php?magick_all"><img src="../images/promote.png" border="0" width="186" height="52" vspace="29" alt="Powered by NetworkEleven" /></a></td>
<td bgcolor="#003399" width="114" height="118" align="right"><img src="../images/sprite.png" width="114" height="118" alt="" /></td>
<td bgcolor="#003399" width="114" height="118" align="right"><a href="http://www.imagemagick.net"><img src="../images/logo.png" width="114" height="118" border="0" alt="ImageMagick logo" /></a></td>
</tr></tbody></table>
<table align="left" border="0" cellpadding="2" cellspacing="2"
summary="Navigation buttons" width="20%">
<tr>
<td>
<form target="_self" action="../index.html"><input type="submit"
title="ImageMagick Home" value=" Home"
style="background-color: #1947A3; background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold" />
</form></td>
<td>
<form target="_self" action="../www/apis.html"><input type="submit"
title="ImageMagick APIs" value="API"
style="background-color: #1947A3; background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold" />
</form></td>
<td>
<form target="_self" action="../www/download.html">
<input type="submit" title="ImageMagick Download" value="Download"
style="background-color: #1947A3; background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold" />
</form></td></tr></table>
<div align="right" style="margin-top:3px; padding-right:4px">
<form action="http://studio.imagemagick.org/Sage/scripts/Sage.cgi">
<input type="TEXT" name="query" size="32" maxlength="255" />
<input type="SUBMIT" name="sa" value="Search"
style="background-color: #1947A3; background-image:url('../images/background.gif'); bgcolor:#003399; color:#fbc713; font-weight:bold" />
</form></div>
<table align="left" border="0" cellpadding="10" cellspacing="0"
style="margin-top:-17px" width="100%">
<tr>
<br />
<td>
<p><b>ImageMagick</b> has a number of functions that allow you to
read, manipulate, write, or display an image. These functions are
accessible through the various <a href="tools.html">tools</a> or
the object-oriented Perl interface,
<a href="perl.html">PerlMagick</a>. However, you can also access
the functions directly from your program through the Magick
Application Programmer Interface. To invoke the functions, write
your program in your favorite language while making calls to the
Magick image functions and link with <tt>libMagick.a</tt>,
<tt>libMagick.so</tt>, or <tt>Magick.dll</tt> depending on your
system.</p>
<p>The Magick Wand API is a new high level interface to the
ImageMagick.  The Wand API is recommended over the core API below.
</p>
<dl>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/magick_wand.html">Magick Wand</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/pixel_iterator.html">Pixel Iterator</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/pixel_wand.html">Pixel Wand</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/drawing_wand.html">Image Vector Drawing</a></dd></dl>
<p>The low level core ImageMagick API, follows.</p>
<dl>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/constitute.html">Constitute an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/composite.html">Composite an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/image.html">Image Methods</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/color.html">Count the Colors in an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/colorspace.html">Dealing with Image
Colorspaces</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/profile.html">Dealing with Image Profiles</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/quantize.html">Reduce the Number of Unique Colors in
an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/segment.html">Segment an Image with Thresholding Fuzzy
c-Means</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/resize.html">Resize an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/transform.html">Transform an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/shear.html">Shear or Rotate an Image by an Arbitrary
Angle</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/enhance.html">Enhance an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/effect.html">Add an Effect</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/fx.html">Add a Special Effect</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/decorate.html">Decorate an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/attribute.html">Set Text Attributes</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/annotate.html">Annotate an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/paint.html">Paint on an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/draw.html">Draw on an Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/montage.html">Create an Image Thumbnail</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/compare.html">Compare an Image to a Reconstructed
Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/display.html">Interactively Display and Edit an
Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/animate.html">Interactively Animate an Image
Sequence</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/cache.html">Get or Set Image Pixels</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/list.html">Working with Image Lists</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/cache_view.html">Working with Cache Views</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/stream.html">The Pixel FIFO</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/blob.html">Read or Write Binary Large OBjects</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/magick.html">Read or List Image formats</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/signature.html">Compute a Message Digest for an
Image</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/registry.html">The Registry</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/error.html">Dealing with Errors</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/memory.html">Memory Allocation</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/resource.html">Monitor or Limit Resource
Consumption</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/monitor.html">Monitor the Progress of an Image
Operation</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/version.html">Get the Version and
Copyrights</a></dd>
<dd><img src="../images/star.gif" alt="*" height="13" width="13" />
<a href="api/deprecate.html">Deprecated Methods</a></dd></dl>
<p>Here is a sample program to get you started. To find out about
all the functions that are available, read the source code. Each
function is delineated with a full rows of percent signs with
comments describing the parameters required for the function and
what it does. For ease in finding a function, they are sorted in
alphabetical order. Most of the image functions are found in
<tt>image.c</tt> and <tt>effects.c</tt>.</p>
<p>Here is a full example of a program, <tt>demo.c</tt>, that reads
a GIF image, creates a thumbnail, and writes it to disk in the MIFF
image format.</p>
<pre>
    #include &lt;stdio.h&gt;
    #include &lt;stdlib.h&gt;
    #include &lt;string.h&gt;
    #include &lt;time.h&gt;
    #include &lt;magick/api.h&gt;

    int main(int argc,char **argv)
    {
      ExceptionInfo
        exception;

      Image
        *image,
        *images,
        *resize_image,
        *thumbnails;

      ImageInfo
        *image_info;

      /*
        Initialize the image info structure and read an image.
      */
      InitializeMagick(*argv);
      GetExceptionInfo(&amp;exception);
      image_info=CloneImageInfo((ImageInfo *) NULL);
      (void) strcpy(image_info-&gt;filename,"image.gif");
      images=ReadImage(image_info,&amp;exception);
      if (exception.severity != UndefinedException)
        CatchException(&amp;exception);
      if (images == (Image *) NULL)
        exit(1);
      /*
        Turn the images into a thumbnail sequence.
      */
      thumbnails=NewImageList();
      while ((image=RemoveFirstImageFromList(&amp;images)) != (Image *) NULL)
      {
        resize_image=ResizeImage(image,106,80,LanczosFilter,1.0,&amp;exception);
        if (resize_image == (Image *) NULL)
          MagickError(exception.severity,exception.reason,exception.description);
        (void) AppendImageToList(&amp;thumbnails,resize_image);
        DestroyImage(image);
      }
      /*
        Write the image as MIFF and destroy it.
      */
      (void) strcpy(thumbnails-&gt;filename,"image.miff");
      WriteImage(image_info,thumbnails);
      DestroyImageList(thumbnails);
      DestroyImageInfo(image_info);
      DestroyExceptionInfo(&amp;exception);
      DestroyMagick();
      return(0);
    }
</pre>
<p>
Now we need to compile. On Unix, the command would look something
like this: 
<pre>
    setenv LD_LIBRARY_PATH /usr/local/lib
    gcc `Magick-config --cflags --cppflags` demo.c `Magick-config --ldflags --libs`
</pre>
Another example is <a href="smile.c">smile.c</a>. Compile and
excute it to display a smiley face on your X server. 
<p>Now lets port the above program to use the Magick Wand API:</p>
<pre>
    #include &lt;stdio.h&gt;
    #include &lt;stdlib.h&gt;
    #include &lt;string.h&gt;
    #include &lt;time.h&gt;
    #include &lt;wand/magick_wand.h&gt;
    
    int main(int argc,char **argv)
    {
    #define ThrowWandException(wand) \
    { \
      char \
        *description; \
     \
      ExceptionType \
        severity; \
     \
      description=MagickGetException(wand,&amp;severity); \
      (void) fprintf(stderr,"%s %s %ld %s\n",GetMagickModule(),description); \
      MagickRelinquishMemory(description); \
      exit(-1); \
    }
    
      MagickBooleanType
        status;
    
      MagickWand
        *magick_wand;
    
      /*
        Read an image.
      */
      magick_wand=NewMagickWand();  
      status=MagickReadImage(magick_wand,"image.gif");
      if (status == MagickFalse)
        ThrowWandException(magick_wand);
      /*
        Turn the images into a thumbnail sequence.
      */
      MagickResetIterator(magick_wand);
      while (MagickNextImage(magick_wand) != MagickFalse)
        MagickResizeImage(magick_wand,106,80,LanczosFilter,1.0);
      /*
        Write the image as MIFF and destroy it.
      */
      status=MagickWriteImages(magick_wand,"image.miff",True);
      if (status == MagickFalse)
        ThrowWandException(magick_wand);
      return(0);
    }
</pre>
<p>To compile, type:</p>
<pre>
    cc `Wand-config --cflags --cppflags` demo.c `Wand-config --ldflags --libs`
</pre>
<p>For <a href='http://studio.imagemagick.org/www/Magick++/index.html'>C++</a>,
use:</p>
<pre>
    c++ `Magick++-config --cxxflags --cppflags` demo.cpp `Magick++-config --ldflags --libs`
</pre>
<hr />
<a href="#top"><img src="../images/top.gif" border="0" width="42"
height="42" align="right" alt="Top of page" /></a>
<form action="http://studio.imagemagick.org/magick/"
style="margin-top:5px"><input type="submit" title="Help!"
value="Help!"
style="background-color: #1947A3; background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold" />
 <small>"Image manipulation software that works like
magick"</small></form></td></tr></table>
</body>
</html>