blob: 8fa4e1d123d990ba28344aa2975d5d75f2320e70 [file] [log] [blame]
Cristyce4a3552015-12-14 13:53:35 -05001
2
3
4
cristy82a2ff22015-05-12 16:41:32 +00005<!DOCTYPE html>
Cristyce4a3552015-12-14 13:53:35 -05006<html lang="en">
cristyad41c0c2012-10-31 00:49:28 +00007<head>
Cristy912a9222016-06-17 15:37:28 -04008 <meta charset="utf-8" />
Cristy3b0b58d2016-11-06 07:40:23 -05009 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
10 <meta http-equiv="x-ua-compatible" content="ie=edge" />
Cristybc232422016-11-22 07:46:18 -050011 <title>Magick++, C++ API @ ImageMagick</title>
Cristyce4a3552015-12-14 13:53:35 -050012 <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."/>
Cristy364a72f2016-11-04 22:38:41 -040015 <meta name="application-url" content="https://www.imagemagick.org"/>
Cristyce4a3552015-12-14 13:53:35 -050016 <meta name="generator" content="PHP"/>
Cristybc232422016-11-22 07:46:18 -050017 <meta name="keywords" content="magick++, c++, api, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
Cristyce4a3552015-12-14 13:53:35 -050018 <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"/>
Cristyfe36f992016-12-29 20:24:13 -050024 <meta name="copyright" content="Copyright (c) 1999-2017 ImageMagick Studio LLC"/>
Cristyce4a3552015-12-14 13:53:35 -050025 <meta name="distribution" content="Global"/>
26 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
Cristy912a9222016-06-17 15:37:28 -040027 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
Cristy6549abb2016-11-10 08:25:55 -050028 <link rel="canonical" href="https://www.imagemagick.org/script/magick++.html"/>
Cristyce4a3552015-12-14 13:53:35 -050029 <link rel="icon" href="../images/wand.png"/>
30 <link rel="shortcut icon" href="../images/wand.ico"/>
Cristybc232422016-11-22 07:46:18 -050031 <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" />
Cristyce4a3552015-12-14 13:53:35 -050032 <link rel="stylesheet" href="css/magick.css"/>
cristyad41c0c2012-10-31 00:49:28 +000033</head>
Cristyce4a3552015-12-14 13:53:35 -050034<body>
cristyad41c0c2012-10-31 00:49:28 +000035<div class="main">
Cristyce4a3552015-12-14 13:53:35 -050036<div class="magick-masthead">
37 <div class="container">
Cristy6549abb2016-11-10 08:25:55 -050038 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
Cristyce4a3552015-12-14 13:53:35 -050039 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>
Cristy9017f3a2017-01-21 10:51:11 -050048 <a class="magick-nav-item " href="download.html">Download</a>
Cristyce4a3552015-12-14 13:53:35 -050049 <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>
Cristy9017f3a2017-01-21 10:51:11 -050052 <a class="magick-nav-item " href="develop.html">Develop</a>
Cristy6549abb2016-11-10 08:25:55 -050053 <a class="magick-nav-item " href="https://www.imagemagick.org/script/search.php">Search</a>
Cristy6fe3b072017-06-08 20:59:09 -040054 <a class="magick-nav-item float-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
Cristyce4a3552015-12-14 13:53:35 -050055 </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>
cristyad41c0c2012-10-31 00:49:28 +000061
cristydcca3fa2010-12-29 21:50:07 +000062<a id="intro"></a>
Cristy6549abb2016-11-10 08:25:55 -050063<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>.
cristydcca3fa2010-12-29 21:50:07 +000065Images support implicit reference counting so that copy constructors
66and assignment incur almost no cost. The cost of actually copying an
67image (if necessary) is done just before modification and this copy
68is managed automagically by Magick++. De-referenced copies are
69automagically deleted. The image objects support value (rather than
70pointer) semantics so it is trivial to support multiple generations
71of an image in memory at one time.
72</p>
cristy2bd2a982011-02-15 00:52:58 +000073<p>Magick++ provides integrated support for the <a href="http://www.sgi.com/tech/stl/">Standard
74Template 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>,
cristyac1b4322013-07-28 13:58:06 +000077and <a href="http://www.sgi.com/tech/stl/Map.html">map</a>) can
cristydcca3fa2010-12-29 21:50:07 +000078be used to write programs similar to those possible with PERL &amp;
79PerlMagick. STL-compatible template versions of ImageMagick's
80list-style operations are provided so that operations may be
81performed on multiple images stored in STL containers.
82</p>
Cristyce4a3552015-12-14 13:53:35 -050083<h2 class="magick-header">Documentation</h2>
cristydcca3fa2010-12-29 21:50:07 +000084<a id="documentation"></a>
Cristy6549abb2016-11-10 08:25:55 -050085<p>Detailed <a href="http://www.imagemagick.org/api/magick++-classes.html">documentation</a> is
cristydcca3fa2010-12-29 21:50:07 +000086provided for all Magick++ classes, class methods, and template
Cristy3b0b58d2016-11-06 07:40:23 -050087functions 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>
Cristyce4a3552015-12-14 13:53:35 -050088<h2 class="magick-header">Obtaining Magick++</h2>
cristydcca3fa2010-12-29 21:50:07 +000089<a id="get"></a>
cristy44443b92015-05-05 00:06:07 +000090<p>Magick++ is included as part of <a href="../index.html">ImageMagick</a>
Cristya3de16b2017-05-14 12:25:22 -040091source releases and may be retrieved via <a href="https://www.imagemagick.org/script/download.html">ftp</a>
Cristyce4a3552015-12-14 13:53:35 -050092or <a href="http://git.imagemagick.org/repos/ImageMagick/Magick++">GIT</a>.
cristydcca3fa2010-12-29 21:50:07 +000093</p>
Cristyce4a3552015-12-14 13:53:35 -050094<h2 class="magick-header">Installation</h2>
cristydcca3fa2010-12-29 21:50:07 +000095<a id="install"></a>
96<p>Once you have the Magick++ sources available, follow these detailed
cristy8ee7f242013-06-20 16:08:44 +000097<a href="../Magick++/Install.html">installation instructions</a> for UNIX and
cristydcca3fa2010-12-29 21:50:07 +000098Windows.
99</p>
Cristyce4a3552015-12-14 13:53:35 -0500100<h2 class="magick-header">Usage</h2>
cristy8ee7f242013-06-20 16:08:44 +0000101<p>A helper script named <code>Magick++-config</code> is installed
cristydcca3fa2010-12-29 21:50:07 +0000102under Unix which assists with recalling compilation options required
103to compile and link programs which use Magick++. For example, the
Cristyce4a3552015-12-14 13:53:35 -0500104following command compiles and links the source file <code>demo.cpp</code>
cristy8ee7f242013-06-20 16:08:44 +0000105to produce the executable <code>demo</code> (notice that quotes are
cristydcca3fa2010-12-29 21:50:07 +0000106backward quotes):
107</p>
Cristyce4a3552015-12-14 13:53:35 -0500108<pre>
cristydcca3fa2010-12-29 21:50:07 +0000109c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \
110 `Magick++-config --ldflags --libs`
111</pre>
Cristyce4a3552015-12-14 13:53:35 -0500112<p>Set the <code>PKG_CONFIG_PATH</code> environment variable if ImageMagick is not in your default system path:</p>
113
114<pre>
115export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
116</pre>
117
cristydcca3fa2010-12-29 21:50:07 +0000118<p>Windows users may get started by manually editing a project file
119for 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>
Cristyce4a3552015-12-14 13:53:35 -0500122<pre>
cristydcca3fa2010-12-29 21:50:07 +0000123int main( int argc, char ** argv) {
124 InitializeMagick(*argv);
125 ...
126</pre>
127<p>This initialization step is not required under Unix, Linux,
128Cygwin, or any other operating environment that supports the notion
Cristyce4a3552015-12-14 13:53:35 -0500129of <var>installing</var> ImageMagick in a known location. </p>
Cristy6549abb2016-11-10 08:25:55 -0500130<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>
Cristyce4a3552015-12-14 13:53:35 -0500131
132<pre class="pre-scrollable">
133#include &lt;Magick++.h>
134#include &lt;iostream>
135
136using namespace std;
137using namespace Magick;
138
139int 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>
cristydcca3fa2010-12-29 21:50:07 +0000166<a id="bugs"></a>
cristy2d67ddd2011-02-13 15:38:23 +0000167<p>Questions regarding usage should be directed to or to report any bugs go to
Cristy364a72f2016-11-04 22:38:41 -0400168<a href="https://www.imagemagick.org/discourse-server/viewforum.html?f=23">Magick++ bug tracking forum</a>.
cristydcca3fa2010-12-29 21:50:07 +0000169</p>
170</div>
Cristyce4a3552015-12-14 13:53:35 -0500171 <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>
Cristye0779712016-07-30 17:25:22 -0400175 <a href="security-policy.html">Security</a>
Cristyce4a3552015-12-14 13:53:35 -0500176 <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>
Cristy6549abb2016-11-10 08:25:55 -0500180 <a href="https://www.imagemagick.org/script/contact.php">Contact Us</a></p>
Cristyfe36f992016-12-29 20:24:13 -0500181 <p><small>© 1999-2017 ImageMagick Studio LLC</small></p>
Cristyce4a3552015-12-14 13:53:35 -0500182 </footer>
183</div><!-- /.container -->
cristyad41c0c2012-10-31 00:49:28 +0000184
Cristyb7f455a2017-03-03 19:30:34 -0500185 <script src="https://localhost/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
Cristy1f1f3a02016-06-01 07:25:42 -0400186 <script src="../js/magick.html"></script>
cristyad41c0c2012-10-31 00:49:28 +0000187</div>
cristyad41c0c2012-10-31 00:49:28 +0000188</body>
189</html>
Cristyd07f4fe2017-06-02 20:36:40 -0400190<!-- Magick Cache 2nd June 2017 20:19 -->