]> granicus.if.org Git - imagemagick/blob - www/magick++.html
...
[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, initial-scale=1, shrink-to-fit=no" />
10   <meta http-equiv="x-ua-compatible" content="ie=edge" />
11   <title>Magick++, C++ API @ ImageMagick</title>
12   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
13   <meta name="application-name" content="ImageMagick"/>
14   <meta name="description" content="ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves."/>
15   <meta name="application-url" content="https://www.imagemagick.org"/>
16   <meta name="generator" content="PHP"/>
17   <meta name="keywords" content="magick++, c++, api, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
18   <meta name="rating" content="GENERAL"/>
19   <meta name="robots" content="INDEX, FOLLOW"/>
20   <meta name="generator" content="ImageMagick Studio LLC"/>
21   <meta name="author" content="ImageMagick Studio LLC"/>
22   <meta name="revisit-after" content="2 DAYS"/>
23   <meta name="resource-type" content="document"/>
24   <meta name="copyright" content="Copyright (c) 1999-2017 ImageMagick Studio LLC"/>
25   <meta name="distribution" content="Global"/>
26   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
27   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
28   <link rel="canonical" href="https://www.imagemagick.org/script/magick++.html"/>
29   <link rel="icon" href="../images/wand.png"/>
30   <link rel="shortcut icon" href="../images/wand.ico"/>
31   <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700" />
32   <link rel="stylesheet" href="css/magick.css"/>
33 </head>
34 <body>
35 <div class="main">
36 <div class="magick-masthead">
37   <div class="container">
38     <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
39          style="display:block"
40          data-ad-client="ca-pub-3129977114552745"
41          data-ad-slot="6345125851"
42          data-ad-format="auto"></ins>
43     <script>
44       (adsbygoogle = window.adsbygoogle || []).push({});
45     </script>
46     <nav class="magick-nav">
47       <a class="magick-nav-item " href="../index.html">Home</a>
48       <a class="magick-nav-item " href="download.html">Download</a>
49       <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
50       <a class="magick-nav-item " href="command-line-processing.html">Command-line</a>
51       <a class="magick-nav-item " href="resources.html">Resources</a>
52       <a class="magick-nav-item " href="develop.html">Develop</a>
53       <a class="magick-nav-item " href="https://www.imagemagick.org/script/search.php">Search</a>
54       <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
55     </nav>
56   </div>
57 </div>
58 <div class="container">
59 <div class="magick-header">
60 <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>
61
62 <a id="intro"></a>
63 <p class="lead magick-description"><a href="http://www.imagemagick.org/api/Magick++/index.html">Magick++ API</a> is the object-oriented C++ API to the <a href="https://www.imagemagick.org/">ImageMagick</a> image-processing library.</p>
64 <p>Magick++ supports an object model which is inspired by <a href="https://www.imagemagick.org/script/perl-magick.html">PerlMagick</a>.
65 Images support implicit reference counting so that copy constructors
66 and assignment incur almost no cost. The cost of actually copying an
67 image (if necessary) is done just before modification and this copy
68 is managed automagically by Magick++. De-referenced copies are
69 automagically deleted. The image objects support value (rather than
70 pointer) semantics so it is trivial to support multiple generations
71 of an image in memory at one time. 
72 </p>
73 <p>Magick++ provides integrated support for the <a href="http://www.sgi.com/tech/stl/">Standard
74 Template Library</a> (STL) so that the powerful containers available
75 (e.g. <a href="http://www.sgi.com/tech/stl/Deque.html">deque</a>,
76 <a href="http://www.sgi.com/tech/stl/Vector.html">vector</a>, <a href="http://www.sgi.com/tech/stl/List.html">list</a>,
77 and <a href="http://www.sgi.com/tech/stl/Map.html">map</a>)  can
78 be used to write programs similar to those possible with PERL &amp;
79 PerlMagick. STL-compatible template versions of ImageMagick's
80 list-style operations are provided so that operations may be
81 performed on multiple images stored in STL containers. 
82 </p>
83 <h2 class="magick-header">Documentation</h2>
84 <a id="documentation"></a>
85 <p>Detailed <a href="http://www.imagemagick.org/api/magick++-classes.html">documentation</a> is
86 provided for all Magick++ classes, class methods, and template
87 functions which comprise the API.  See a <a href="https://www.imagemagick.org/Magick++/tutorial/Magick++_tutorial.pdf">  Gentle Introduction to Magick++</a> for an introductory tutorial to Magick++.  We include the <a href="https://www.imagemagick.org/Magick++/tutorial/Magick++_tutorial.odt" >source</a> if you want to correct, enhance, or expand the tutorial.</p>
88 <h2 class="magick-header">Obtaining Magick++</h2>
89 <a id="get"></a>
90 <p>Magick++ is included as part of <a href="../index.html">ImageMagick</a>
91 source releases and may be retrieved via <a href="https://www.imagemagick.org/script/mirror.html">ftp</a>
92 or <a href="http://git.imagemagick.org/repos/ImageMagick/Magick++">GIT</a>.
93 </p>
94 <h2 class="magick-header">Installation</h2>
95 <a id="install"></a>
96 <p>Once you have the Magick++ sources available, follow these detailed
97 <a href="../Magick++/Install.html">installation instructions</a> for UNIX and
98 Windows. 
99 </p>
100 <h2 class="magick-header">Usage</h2>
101 <p>A helper script named <code>Magick++-config</code> is installed
102 under Unix which assists with recalling compilation options required
103 to compile and link programs which use Magick++. For example, the
104 following command compiles and links the source file <code>demo.cpp</code>
105 to produce the executable <code>demo</code> (notice that quotes are
106 backward quotes): 
107 </p>
108 <pre>
109 c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \
110   `Magick++-config --ldflags --libs`
111 </pre>
112 <p>Set the <code>PKG_CONFIG_PATH</code> environment variable if ImageMagick is not in your default system path:</p>
113
114 <pre>
115 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
116 </pre>
117
118 <p>Windows users may get started by manually editing a project file
119 for one of the Magick++ demo programs. 
120 </p>
121 <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>
122 <pre>
123 int main( int argc, char ** argv) {
124   InitializeMagick(*argv);
125   ...
126 </pre>
127 <p>This initialization step is not required under Unix, Linux,
128 Cygwin, or any other operating environment that supports the notion
129 of <var>installing</var> ImageMagick in a known location.  </p>
130 <p>Here is a example program that utilizes the Magick++ API to get you started, <a href="http://www.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>
131
132 <pre class="pre-scrollable">
133 #include &lt;Magick++.h> 
134 #include &lt;iostream> 
135
136 using namespace std; 
137 using namespace Magick; 
138
139 int main(int argc,char **argv) 
140
141   InitializeMagick(*argv);
142
143   // Construct the image object. Seperating image construction from the 
144   // the read operation ensures that a failure to read the image file 
145   // doesn't render the image object useless. 
146   Image image;
147   try { 
148     // Read a file into image object 
149     image.read( "logo:" );
150
151     // Crop the image to specified size (width, height, xOffset, yOffset)
152     image.crop( Geometry(100,100, 100, 100) );
153
154     // Write the image to a file 
155     image.write( "logo.png" ); 
156   } 
157   catch( Exception &amp;error_ ) 
158     { 
159       cout &lt;&lt; "Caught exception: " &lt;&lt; error_.what() &lt;&lt; endl; 
160       return 1; 
161     } 
162   return 0; 
163 }
164 </pre>
165 <h2 class="magick-header">Reporting Bugs</h2>
166 <a id="bugs"></a>
167 <p>Questions regarding usage should be directed to or to report any bugs go to
168 <a href="https://www.imagemagick.org/discourse-server/viewforum.html?f=23">Magick++ bug tracking forum</a>.
169 </p>
170 </div>
171   <footer class="magick-footer">
172     <p><a href="support.html">Donate</a> •
173      <a href="sitemap.html">Sitemap</a> •
174     <a href="links.html">Related</a> •
175     <a href="security-policy.html">Security</a> •
176     <a href="architecture.html">Architecture</a>
177 </p>
178     <p><a href="magick++.html#">Back to top</a> •
179     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
180     <a href="https://www.imagemagick.org/script/contact.php">Contact Us</a></p>
181         <p><small>© 1999-2017 ImageMagick Studio LLC</small></p>
182   </footer>
183 </div><!-- /.container -->
184
185   <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
186   <script src="../js/magick.html"></script>
187 </div>
188 </body>
189 </html>
190 <!-- Magick Cache 21st January 2017 12:17 -->