blob: e23b911bdf2a21af1f8c33222dfde8f2e55cd24e [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<title>ImageMagick: Magick++, C++ API for ImageMagick</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="application-name" content="ImageMagick"/>
<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."/>
<meta name="application-url" content=""/>
<meta name="generator" content="PHP"/>
<meta name="keywords" content="magick++, c++, api, for, imagemagick, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
<meta name="rating" content="GENERAL"/>
<meta name="robots" content="INDEX, FOLLOW"/>
<meta name="generator" content="ImageMagick Studio LLC"/>
<meta name="author" content="ImageMagick Studio LLC"/>
<meta name="revisit-after" content="2 DAYS"/>
<meta name="resource-type" content="document"/>
<meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
<meta name="distribution" content="Global"/>
<meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
<meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
<link rel="icon" href="../images/wand.png"/>
<link rel="shortcut icon" href="../images/wand.ico"/>
<link rel="stylesheet" type="text/css" href=",400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
<link rel="stylesheet" href="css/magick.css"/>
<div class="main">
<div class="magick-masthead">
<div class="container">
<script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
(adsbygoogle = window.adsbygoogle || []).push({});
<nav class="magick-nav">
<a class="magick-nav-item " href="../index.html">Home</a>
<a class="magick-nav-item " href="binary-releases.html">Download</a>
<a class="magick-nav-item " href="command-line-tools.html">Tools</a>
<a class="magick-nav-item " href="command-line-processing.html">Command-line</a>
<a class="magick-nav-item " href="resources.html">Resources</a>
<a class="magick-nav-item " href="api.html">Develop</a>
<a class="magick-nav-item " href="">Search</a>
<a class="magick-nav-item pull-right" href="">Community</a>
<div class="container">
<div class="magick-header">
<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>
<a id="intro"></a>
<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>
<p>Magick++ supports an object model which is inspired by <a href="perl-magick.html">PerlMagick</a>.
Images support implicit reference counting so that copy constructors
and assignment incur almost no cost. The cost of actually copying an
image (if necessary) is done just before modification and this copy
is managed automagically by Magick++. De-referenced copies are
automagically deleted. The image objects support value (rather than
pointer) semantics so it is trivial to support multiple generations
of an image in memory at one time.
<p>Magick++ provides integrated support for the <a href="">Standard
Template Library</a> (STL) so that the powerful containers available
(e.g. <a href="">deque</a>,
<a href="">vector</a>, <a href="">list</a>,
and <a href="">map</a>) can
be used to write programs similar to those possible with PERL &amp;
PerlMagick. STL-compatible template versions of ImageMagick's
list-style operations are provided so that operations may be
performed on multiple images stored in STL containers.
<h2 class="magick-header">Documentation</h2>
<a id="documentation"></a>
<p>Detailed <a href="api/magick++-classes.html">documentation</a> is
provided for all Magick++ classes, class methods, and template
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>
<h2 class="magick-header">Obtaining Magick++</h2>
<a id="get"></a>
<p>Magick++ is included as part of <a href="../index.html">ImageMagick</a>
source releases and may be retrieved via <a href="download.html">ftp</a>
or <a href="">GIT</a>.
<h2 class="magick-header">Installation</h2>
<a id="install"></a>
<p>Once you have the Magick++ sources available, follow these detailed
<a href="../Magick++/Install.html">installation instructions</a> for UNIX and
<h2 class="magick-header">Usage</h2>
<p>A helper script named <code>Magick++-config</code> is installed
under Unix which assists with recalling compilation options required
to compile and link programs which use Magick++. For example, the
following command compiles and links the source file <code>demo.cpp</code>
to produce the executable <code>demo</code> (notice that quotes are
backward quotes):
c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \
`Magick++-config --ldflags --libs`
<p>Set the <code>PKG_CONFIG_PATH</code> environment variable if ImageMagick is not in your default system path:</p>
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
<p>Windows users may get started by manually editing a project file
for one of the Magick++ demo programs.
<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>
int main( int argc, char ** argv) {
<p>This initialization step is not required under Unix, Linux,
Cygwin, or any other operating environment that supports the notion
of <var>installing</var> ImageMagick in a known location. </p>
<p>Here is a example program that utilizes the Magick++ API to get you started, <a href="../source/magick++.cpp">magick++.cpp</a>. It reads an image, crops it, and writes it to disk in the PNG image format.</p>
<pre class="pre-scrollable">
#include &lt;Magick++.h>
#include &lt;iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
// Construct the image object. Seperating image construction from the
// the read operation ensures that a failure to read the image file
// doesn't render the image object useless.
Image image;
try {
// Read a file into image object "logo:" );
// Crop the image to specified size (width, height, xOffset, yOffset)
image.crop( Geometry(100,100, 100, 100) );
// Write the image to a file
image.write( "logo.png" );
catch( Exception &amp;error_ )
cout &lt;&lt; "Caught exception: " &lt;&lt; error_.what() &lt;&lt; endl;
return 1;
return 0;
<h2 class="magick-header">Reporting Bugs</h2>
<a id="bugs"></a>
<p>Questions regarding usage should be directed to or to report any bugs go to
<a href="">Magick++ bug tracking forum</a>.
<footer class="magick-footer">
<p><a href="support.html">Donate</a>
<a href="sitemap.html">Sitemap</a>
<a href="links.html">Related</a>
<a href="architecture.html">Architecture</a>
<p><a href="magick++.html#">Back to top</a>
<a href=";search=0x89AB63D48277377A">Public Key</a>
<a href="">Contact Us</a></p>
<p><small>© 1999-2016 ImageMagick Studio LLC</small></p>
</div><!-- /.container -->
<script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../js/magick.html"></script>