]> granicus.if.org Git - imagemagick/blob - www/magick++.html
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18265
[imagemagick] / www / magick++.html
1
2
3
4
5 <!DOCTYPE html>
6 <html lang="en">
7 <head>
8   <meta charset="utf-8"  />
9   <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no"  />
10   <title>ImageMagick - Magick++, C++ API</title>
11   <meta name="application-name" content="ImageMagick" />
12   <meta name="description" content="ImageMagick® creates, edits, composes, and converts bitmap images. Resize an image, crop it, change its shades and colors, add captions, and more." />
13   <meta name="application-url" content="https://imagemagick.org" />
14   <meta name="generator" content="PHP" />
15   <meta name="keywords" content="magick++, c++, api, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert" />
16   <meta name="rating" content="GENERAL" />
17   <meta name="robots" content="INDEX, FOLLOW" />
18   <meta name="generator" content="ImageMagick Studio LLC" />
19   <meta name="author" content="ImageMagick Studio LLC" />
20   <meta name="revisit-after" content="2 DAYS" />
21   <meta name="resource-type" content="document" />
22   <meta name="copyright" content="Copyright (c) 1999-2019 ImageMagick Studio LLC" />
23   <meta name="distribution" content="Global" />
24   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" />
25   <meta property='og:url' content='../' />
26   <meta property='og:title' content='ImageMagick' />
27   <meta property='og:image' content='../images/logo.png' />
28   <meta property='og:type' content='website' />
29   <meta property='og:site_name' content='ImageMagick' />
30   <meta property='og:description' content="Convert, Edit, or Compose Bitmap Images" />
31   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
32   <link href="magick++.html" rel="canonical" />
33   <link href="../images/wand.png" rel="icon" />
34   <link href="../images/wand.ico" rel="shortcut icon" />
35   <link href="assets/magick.css" rel="stylesheet" />
36 </head>
37 <body>
38   <header>
39   <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
40     <a class="navbar-brand" href="../index.html"><img class="d-block" id="icon" alt="ImageMagick" width="32" height="32" src="../images/wand.ico"/></a>
41     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMagick" aria-controls="navbarsMagick" aria-expanded="false" aria-label="Toggle navigation">
42       <span class="navbar-toggler-icon"></span>
43     </button>
44
45     <div class="navbar-collapse collapse" id="navbarsMagick" style="">
46     <ul class="navbar-nav mr-auto">
47       <li class="nav-item ">
48         <a class="nav-link" href="../index.html">Home <span class="sr-only">(current)</span></a>
49       </li>
50       <li class="nav-item ">
51         <a class="nav-link" href="download.html">Download</a>
52       </li>
53       <li class="nav-item ">
54         <a class="nav-link" href="command-line-tools.html">Tools</a>
55       </li>
56       <li class="nav-item ">
57         <a class="nav-link" href="command-line-processing.html">Command-line</a>
58       </li>
59       <li class="nav-item ">
60         <a class="nav-link" href="resources.html">Resources</a>
61       </li>
62       <li class="nav-item ">
63         <a class="nav-link" href="develop.html">Develop</a>
64       </li>
65       <li class="nav-item">
66         <a class="nav-link" target="_blank" href="https://imagemagick.org/discourse-server/">Community</a>
67       </li>
68     </ul>
69     <form class="form-inline my-2 my-lg-0" action="https://imagemagick.org/script/search.php">
70       <input class="form-control mr-sm-2" type="text" name="q" placeholder="Search" aria-label="Search">
71       <button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="sa">Search</button>
72     </form>
73     </div>
74   </nav>
75   <div class="container">
76    <script async="async" src="https://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
77          style="display:block"
78          data-ad-client="ca-pub-3129977114552745"
79          data-ad-slot="6345125851"
80          data-full-width-responsive="true"
81          data-ad-format="horizontal"></ins>
82     <script>
83       (adsbygoogle = window.adsbygoogle || []).push({});
84     </script>
85
86   </div>
87   </header>
88   <main class="container">
89     <div class="magick-template">
90 <div class="magick-header">
91 <p class="text-center"><a href="magick++.html#documentation">Documentation</a> • <a href="magick++.html#get">Obtaining Magick++</a> • <a href="magick++.html#install">Installation</a> • <a href="magick++.html#bugs">Reporting Bugs</a></p>
92
93 <a class="anchor" id="intro"></a>
94 <p class="lead magick-description"><a href="api/Magick++/index.html">Magick++ API</a> is the object-oriented C++ API to the <a href="../index.html">ImageMagick</a> image-processing library.</p>
95 <p>Magick++ supports an object model which is inspired by <a href="perl-magick.html">PerlMagick</a>.
96 Images support implicit reference counting so that copy constructors
97 and assignment incur almost no cost. The cost of actually copying an
98 image (if necessary) is done just before modification and this copy
99 is managed automagically by Magick++. De-referenced copies are
100 automagically deleted. The image objects support value (rather than
101 pointer) semantics so it is trivial to support multiple generations
102 of an image in memory at one time. 
103 </p>
104 <p>Magick++ provides integrated support for the <a href="http://www.sgi.com/tech/stl/">Standard
105 Template Library</a> (STL) so that the powerful containers available
106 (e.g. <a href="http://www.sgi.com/tech/stl/Deque.html">deque</a>,
107 <a href="http://www.sgi.com/tech/stl/Vector.html">vector</a>, <a href="http://www.sgi.com/tech/stl/List.html">list</a>,
108 and <a href="http://www.sgi.com/tech/stl/Map.html">map</a>)  can
109 be used to write programs similar to those possible with PERL &amp;
110 PerlMagick. STL-compatible template versions of ImageMagick's
111 list-style operations are provided so that operations may be
112 performed on multiple images stored in STL containers. 
113 </p>
114 <h2>Documentation</h2>
115 <a class="anchor" id="documentation"></a>
116 <p>Detailed <a href="api/magick++-classes.html">documentation</a> is
117 provided for all Magick++ classes, class methods, and template
118 functions which comprise the API.  See a <a href="../Magick++/tutorial/Magick++_tutorial.pdf">  Gentle Introduction to Magick++</a> for an introductory tutorial to Magick++.  We include the <a href="../Magick++/tutorial/Magick++_tutorial.odt" >source</a> if you want to correct, enhance, or expand the tutorial.</p>
119 <h2>Obtaining Magick++</h2>
120 <a class="anchor" id="get"></a>
121 <p>Magick++ is included as part of <a href="../www/api/composite.html">ImageMagick</a>
122 source releases and may be retrieved via <a href="download.html">HTTP</a>
123 or <a href="https://github.com/ImageMagick/ImageMagick/tree/master/Magick%2B%2B">GitHub</a>.
124 </p>
125 <h2>Installation</h2>
126 <a class="anchor" id="install"></a>
127 <p>Once you have the Magick++ sources available, follow these detailed
128 <a href="../Magick++/Install.html">installation instructions</a> for UNIX and
129 Windows. 
130 </p>
131 <h2>Usage</h2>
132 <p>A helper script named <code>Magick++-config</code> is installed
133 under Unix which assists with recalling compilation options required
134 to compile and link programs which use Magick++. For example, the
135 following command compiles and links the source file <code>demo.cpp</code>
136 to produce the executable <code>demo</code> (notice that quotes are
137 backward quotes): 
138 </p>
139 <pre class="highlight"><code>c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \
140   `Magick++-config --ldflags --libs`
141 </code></pre>
142 <p>Set the <code>PKG_CONFIG_PATH</code> environment variable if ImageMagick is not in your default system path:</p>
143
144 <pre class="highlight"><code>export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
145 </code></pre>
146
147 <p>Windows users may get started by manually editing a project file
148 for one of the Magick++ demo programs. 
149 </p>
150 <p>Note, under Windows (and possibly the Mac) it may be necessary to initialize the ImageMagick library prior to using the Magick++ library. This initialization is performed by passing the path to the ImageMagick DLLs (assumed to be in the same directory as your program) to the InitializeMagick() function call. This is commonly performed by providing the path to your program (argv[0]) as shown in the following example: </p>
151 <pre class="highlight"><code>int main( int argc, char ** argv) {
152   InitializeMagick(*argv);
153   ...
154 </code></pre>
155 <p>This initialization step is not required under Unix, Linux,
156 Cygwin, or any other operating environment that supports the notion
157 of <var>installing</var> ImageMagick in a known location.  </p>
158 <p>Here is a example program that utilizes the Magick++ API to get you started, <a href="https://imagemagick.org/source/magick++.cpp">magick++.cpp</a>. It reads an image, crops it, and writes it to disk in the PNG image format.</p>
159
160 <pre class="pre-scrollable"><code>
161 #include &lt;Magick++.h> 
162 #include &lt;iostream> 
163
164 using namespace std; 
165 using namespace Magick; 
166
167 int main(int argc,char **argv) 
168
169   InitializeMagick(*argv);
170
171   // Construct the image object. Seperating image construction from the 
172   // the read operation ensures that a failure to read the image file 
173   // doesn't render the image object useless. 
174   Image image;
175   try { 
176     // Read a file into image object 
177     image.read( "logo:" );
178
179     // Crop the image to specified size (width, height, xOffset, yOffset)
180     image.crop( Geometry(100,100, 100, 100) );
181
182     // Write the image to a file 
183     image.write( "logo.png" ); 
184   } 
185   catch( Exception &amp;error_ ) 
186     { 
187       cout &lt;&lt; "Caught exception: " &lt;&lt; error_.what() &lt;&lt; endl; 
188       return 1; 
189     } 
190   return 0; 
191 }
192 </code></pre>
193 <h2>Reporting Bugs</h2>
194 <a class="anchor" id="bugs"></a>
195 <p>Questions regarding usage should be directed to or to report any bugs go to
196 <a href="https://imagemagick.org/discourse-server//viewforum.html?f=23">Magick++ bug tracking forum</a>.
197 </p>
198 </div>
199     </div>
200   </main><!-- /.container -->
201   <footer class="magick-footer">
202     <p><a href="security-policy.html">Security</a> •
203     <a href="architecture.html">Architecture</a>
204      
205     <a href="magick++.html#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../images/wand.ico"/></a>
206      
207     <a href="links.html">Related</a> •
208      <a href="sitemap.html">Sitemap</a>
209     <br/>
210     <a href="support.html">Donate</a> •
211     <a href="http://pgp.mit.edu/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
212     <a href="https://imagemagick.org/script/contact.php">Contact Us</a> 
213     <br/>
214     <small>© 1999-2019 ImageMagick Studio LLC</small></p>
215   </footer>
216
217   <!-- Javascript assets -->
218   <script src="assets/magick.js" crossorigin="anonymous"></script>
219   <script>window.jQuery || document.write('<script src="https://localhost/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>')</script>
220 </body>
221 </html>
222 <!-- Magick Cache 2nd September 2019 14:28 -->