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
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.16: http://docutils.sourceforge.net/" />
<title>GraphicsMagick Wand C API</title>
<link rel="stylesheet" href="../docutils-articles.css" type="text/css" />
</head>
<body>
<div class="banner">
<img src="../images/gm-107x76.png" alt="GraphicMagick logo" width="107" height="76" />
<span class="title">GraphicsMagick</span>
<form action="http://www.google.com/search">
<input type="hidden" name="domains" value="www.graphicsmagick.org" />
<input type="hidden" name="sitesearch" value="www.graphicsmagick.org" />
<span class="nowrap"><input type="text" name="q" size="25" maxlength="255" /> <input type="submit" name="sa" value="Search" /></span>
</form>
</div>
<div class="navmenu">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a href="../project.html">Project</a></li>
<li><a href="../download.html">Download</a></li>
<li><a href="../README.html">Install</a></li>
<li><a href="../Hg.html">Source</a></li>
<li><a href="../NEWS.html">News</a> </li>
<li><a href="../utilities.html">Utilities</a></li>
<li><a href="../programming.html">Programming</a></li>
<li><a href="../reference.html">Reference</a></li>
</ul>
</div>
<div class="document" id="graphicsmagick-wand-c-api">
<h1 class="title">GraphicsMagick Wand C API</h1>
<!-- -*- mode: rst -*- -->
<!-- This text is in reStucturedText format, so it may look a bit odd. -->
<!-- See http://docutils.sourceforge.net/rst.html for details. -->
<p>The GraphicsMagick Wand C library provides a mid-level abstract C
language programming interface for GraphicsMagick. It is originally
based on the Wand API provided in ImageMagick as of August 2003.
After August 2003, ImageMagick changed its license to one unusable by
GraphicsMagick so this version of the Wand library is not completely
in sync with the current ImageMagick version.</p>
<p>The API is divided into a number of categories. While reading this
documentation, please reference the <a class="reference external" href="../api/types.html">types</a> documentation as required:</p>
<blockquote>
<ul class="simple">
<li><a class="reference external" href="drawing_wand.html">Drawing</a>: Wand vector drawing interfaces.</li>
<li><a class="reference external" href="magick_wand.html">Magick</a>: Wand image processing interfaces</li>
<li><a class="reference external" href="pixel_wand.html">Pixel</a>: Wand pixel access/update interfaces</li>
</ul>
</blockquote>
<p>The following is a simple example program which (assuming the program
name is <cite>rotate</cite>) is executed similar to <cite>rotate infile outfile</cite>. It
reads from file <cite>infile</cite>, rotates the image 30 degrees using a black
background, and writes the result to file <cite>outfile</cite>:</p>
<pre class="literal-block">
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <wand/magick_wand.h>
int main(int argc,char **argv)
{
MagickWand *magick_wand;
MagickPassFail status = MagickPass;
const char *infile, *outfile;
if (argc != 3)
{
fprintf(stderr,"Usage: %s: infile outfile\n",argv[0]);
return 1;
}
infile=argv[1];
outfile=argv[2];
// Initialize GraphicsMagick API
InitializeMagick(*argv);
// Allocate Wand handle
magick_wand=NewMagickWand();
// Read input image file
if (status == MagickPass)
{
status = MagickReadImage(magick_wand,infile);
}
// Rotate image clockwise 30 degrees with black background
if (status == MagickPass)
{
PixelWand *background;
background=NewPixelWand();
PixelSetColor(background,"#000000");
status = MagickRotateImage(magick_wand,background,30);
DestroyPixelWand(background);
}
// Write output file
if (status == MagickPass)
{
status = MagickWriteImage(magick_wand,outfile);
}
// Diagnose any error
if (status != MagickPass)
{
char *description;
ExceptionType severity;
description=MagickGetException(magick_wand,&severity);
(void) fprintf(stderr,"%.1024s (severity %d)\n",
description,severity);
}
// Release Wand handle
DestroyMagickWand(magick_wand);
// Destroy GraphicsMagick API
DestroyMagick();
return (status == MagickPass ? 0 : 1);
}
</pre>
<p>To compile on Unix, the command looks something like this:</p>
<pre class="literal-block">
gcc -o demo demo.c -O `GraphicsMagickWand-config --cppflags --ldflags --libs`
</pre>
<p>The GraphicsMagickWand-config script reproduces the options which were used to
compile the GraphicsMagick wand library. Using compatible options ensures that
your program will compile and run.</p>
</div>
<hr class="docutils">
<div class="document">
<p><a href="../Copyright.html">Copyright</a> © GraphicsMagick Group 2002 - 2020<!--SPONSOR_LOGO--></p>
</div>
</body>
</html>
|