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