blob: e286cd6f24390907fd458b30e5e21c329c6449e2 [file] [log] [blame]
cristyba1758d2011-06-03 01:29:12 +00001
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4<html version="-//W3C//DTD XHTML 1.1//EN"
5 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
6 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7 xsi:schemaLocation="http://www.w3.org/1999/xhtml
8 http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
9<head>
10 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
cristy1efc1ab2011-08-01 14:47:02 +000011 <meta name="google-site-verification" content="MxsMq6bdLOx0KSuz1MY6yG9ZTIJ7_7DVRfl5NCAT5Yg"/>
cristyba1758d2011-06-03 01:29:12 +000012 <title>ImageMagick: Porting to ImageMagick Version 7</title>
13 <meta http-equiv="Content-Language" content="en-US"/>
14 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
15 <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
16 <meta name="Application-name" content="ImageMagick"/>
cristye6e84152011-06-06 14:16:49 +000017 <meta name="Description" content="Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats. In addition resize, rotate, shear, distort and transform images automagically."/>
cristyba1758d2011-06-03 01:29:12 +000018 <meta name="Application-url" content="http://www.imagemagick.org"/>
19 <meta name="Generator" content="PHP"/>
cristyeed6cb62012-01-28 19:38:34 +000020 <meta name="Keywords" content="porting, to, imagemagick, version, 7, ImageMagick, PerlMagick, image processing, OpenMP, software development library, image, photo, software, Magick++, MagickWand"/>
cristyba1758d2011-06-03 01:29:12 +000021 <meta name="Rating" content="GENERAL"/>
22 <meta name="Robots" content="INDEX, FOLLOW"/>
23 <meta name="Generator" content="ImageMagick Studio LLC"/>
24 <meta name="Author" content="ImageMagick Studio LLC"/>
25 <meta name="Revisit-after" content="2 DAYS"/>
26 <meta name="Resource-type" content="document"/>
cristy1454be72011-12-19 01:52:48 +000027 <meta name="Copyright" content="Copyright (c) 1999-2012 ImageMagick Studio LLC"/>
cristyba1758d2011-06-03 01:29:12 +000028 <meta name="Distribution" content="Global"/>
29 <link rel="icon" href="../images/wand.png"/>
30 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon"/>
cristy29c5c992011-06-25 13:58:49 +000031 <link rel="canonical" href="http://www.imagemagick.org" />
cristyba1758d2011-06-03 01:29:12 +000032 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>
cristyeed6cb62012-01-28 19:38:34 +000033 <!-- Add jQuery library -->
34 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
35
36 <!-- Optionaly include easing and/or mousewheel plugins -->
37 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.easing-1.3.pack.js"></script>
38 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>
39
40 <!-- Add fancyBox -->
41 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/jquery.fancybox.css?v=2.0.3" type="text/css" media="screen" />
42 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/jquery.fancybox.pack.js?v=2.0.3"></script>
43
44 <!-- Optionaly include button and/or thumbnail helpers -->
45 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.css?v=2.0.3" type="text/css" media="screen" />
46 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-buttons.js?v=2.0.3"></script>
47
48 <link rel="stylesheet" href="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.css?v=2.0.3" type="text/css" media="screen" />
49 <script type="text/javascript" src="http://www.imagemagick.org/fancybox/helpers/jquery.fancybox-thumbs.js?v=2.0.3"></script>
50 <script type="text/javascript">
51 $(document).ready(function() {
52 $(".fancybox").fancybox();
53 });
54 </script>
55 <!-- ImageMagick style -->
cristyba1758d2011-06-03 01:29:12 +000056 <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
57 <style type="text/css" media="all">
58 @import url("../www/magick.css");
59 </style>
cristyba1758d2011-06-03 01:29:12 +000060</head>
61
62<body id="www-imagemagick-org">
63<div class="titlebar">
64<div style="margin: 17px auto; float: left;">
65 <script type="text/javascript">
66 <!--
67 google_ad_client = "pub-3129977114552745";
68 google_ad_slot = "5439289906";
69 google_ad_width = 728;
70 google_ad_height = 90;
71 //-->
72 </script>
73 <script type="text/javascript"
74 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
75 </script>
76</div>
77<a href="http://www.imagemagick.org/discourse-server/">
78 <img src="../images/logo.jpg"
79 alt="ImageMagick Logo"
80 style="width: 123px; height: 118px; border: 0px; float: right;" /></a>
81<a href="../index.html">
82 <img src="../images/sprite.jpg"
83 alt="ImageMagick Sprite"
84 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
85</div>
86
87<div class="westbar">
88
89<div class="menu">
90 <a title="About ImageMagick" href="../index.html">About ImageMagick</a>
91</div>
cristyba1758d2011-06-03 01:29:12 +000092<div class="menu">
93 <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
94</div>
95<div class="sub">
96 <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
97</div>
98<div class="sub">
99 <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
100</div>
101<div class="sub">
cristye6e84152011-06-06 14:16:49 +0000102 <a title="Binary Release: iOS" href="../www/binary-releases.html#iOS">iOS</a>
cristyba1758d2011-06-03 01:29:12 +0000103</div>
104<div class="sub">
105 <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
106</div>
107<div class="sep"></div>
108<div class="menu">
109 <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
110</div>
111<div class="sub">
112 <a title="Command-line Tools: Processing" href="../www/command-line-processing.html">Processing</a>
113</div>
114<div class="sub">
115 <a title="Command-line Tools: Options" href="../www/command-line-options.html">Options</a>
116</div>
117<div class="sub">
118 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
119</div>
120<div class="menu">
121 <a title="Program Interfaces" href="../www/api.html">Program Interfaces</a>
122</div>
123<div class="sub">
124 <a title="Program Interface: MagickWand" href="../www/magick-wand.html">MagickWand</a>
125</div>
126<div class="sub">
127 <a title="Program Interface: MagickCore" href="../www/magick-core.html">MagickCore</a>
128</div>
129<div class="sub">
130 <a title="Program Interface: PerlMagick" href="../www/perl-magick.html">PerlMagick</a>
131</div>
132<div class="sub">
133 <a title="Program Interface: Magick++" href="../www/magick++.html">Magick++</a>
134</div>
135<div class="sep"></div>
136<div class="menu">
137 <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
138</div>
139<div class="sub">
140 <a title="Install from Source: Unix" href="../www/install-source.html#unix">Unix</a>
141</div>
142<div class="sub">
143 <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
144 </div>
145<div class="menu">
146 <a title="Resources" href="../www/resources.html">Resources</a>
147</div>
148<div class="menu">
149 <a title="Architecture" href="../www/architecture.html">Architecture</a>
150</div>
151<div class="menu">
152 <a title="Download" href="../www/download.html">Download</a>
153</div>
154<div class="sep"></div>
155<div class="menu">
156 <a title="Search" href="../www/search.html">Search</a>
157</div>
158<div class="sep"></div>
159<div class="menu">
160 <a title="Site Map" href="../www/sitemap.html">Site Map</a>
161</div>
162<div class="sub">
163 <a title="Site Map: Links" href="../www/links.html">Links</a>
164</div>
165<div class="sep"></div>
cristyeed6cb62012-01-28 19:38:34 +0000166<div class="menu">
cristyba1758d2011-06-03 01:29:12 +0000167 <a rel="follow" title="Sponsors" href="../www/sponsors.html">Sponsors:</a>
168
cristyeed6cb62012-01-28 19:38:34 +0000169 <a href="http://www.networkredux.com"> <img src="../images/networkredux.png" width="140" height="31" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a>
170 <a href="http://www.dinodirect.com/ipads-tablets/"> <img src="../images/dino-direct.jpg" width="140" height="90" alt="[sponsor]" style="margin-top: 4px; margin-left: 4px; border: 0px; float: left;" /></a><!-- 201204010120 mickey@163... -->
cristyba1758d2011-06-03 01:29:12 +0000171<div class="sponsbox">
cristyeed6cb62012-01-28 19:38:34 +0000172<div class="sponsor">
173 <a rel="follow" title="Android Tablet" href="http://www.dinodirect.com/ipads-tablets/">Android Tablet</a><!-- 201204010120 mickey@163... -->
cristy81492d62011-06-07 16:41:42 +0000174</div>
cristyeed6cb62012-01-28 19:38:34 +0000175<div class="sponsor">
cristyaf894d72011-08-06 23:03:10 +0000176 <a rel="follow" title="Sponsor: Web Hosting" href="http://www.micfo.com">Web Hosting</a><!-- 209901010090s golestan -->
cristy1efc1ab2011-08-01 14:47:02 +0000177</div>
cristyeed6cb62012-01-28 19:38:34 +0000178<div class="sponsor">
179 <a rel="follow" title="Sponsor: Autos Part" href="http://www.pkwteile.de/autoteile">Autos Part</a><!-- 201203010270 info@pkwte... -->
cristy84134182011-06-15 22:59:00 +0000180</div>
cristyeed6cb62012-01-28 19:38:34 +0000181<div class="sponsor">
182 <a rel="follow" title="Sponsor: Web Site Hosting" href="http://webhostinggeeks.com">Web Site Hosting</a><!-- 201302010900 funds@enmob... -->
cristy81492d62011-06-07 16:41:42 +0000183</div>
cristyeed6cb62012-01-28 19:38:34 +0000184<div class="sponsor">
185 <a rel="follow" title="Sponsor: Tenant Check" href="http://www.rentmethod.com/">Tenant Check</a><!-- 201203010090 chris@rentm... -->
cristyba1758d2011-06-03 01:29:12 +0000186</div>
cristyeed6cb62012-01-28 19:38:34 +0000187<div class="sponsor">
188 <a rel="follow" title="Sponsor: VPS" href="http://www.interdominios.com/vps">VPS</a><!-- 201204010090 barsh@inter... -->
cristyaf894d72011-08-06 23:03:10 +0000189</div>
cristyeed6cb62012-01-28 19:38:34 +0000190<div class="sponsor">
191 <a rel="follow" title="Sponsor: Premium Quality Stock Photos" href="http://www.f1online.pro/en/">Premium Quality Stock Photos</a><!-- 2012080100540 ... -->
192</div>
193<div class="sponsor">
194 <a rel="follow" title="Sponsor: Search engine optimisation" href="http://www.seomoves.com.au">Search engine optimisation</a><!-- 201301010090s jen@seo lowprofilelinks -->
195</div>
196<div class="sponsor">
197 <a rel="follow" title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 2012070100250 ... -->
198</div>
199<div class="sponsor">
200 <a rel="follow" title="Sponsor: Managed Server" href="http://www.robhost.de">Managed Server</a><!-- 201210010720 klikics... -->
201</div>
202<div class="sponsor">
203 <a rel="follow" title="Sponsor: Stock Photography" href="http://www.fotosearch.com/">Stock Photography</a><!-- 2012040100250 ... -->
204</div>
205<div class="sponsor">
206 <a rel="follow" title="Sponsor: Autoteile" href="http://www.q11-shop.de">Autoteile</a><!-- 201205010540 suvalj -->
207</div>
208<div class="sponsor">
209 <a rel="follow" title="Sponsor: Royalty Free Stock Images" href="http://www.canstockphoto.com/">Royalty Free Stock Images</a><!-- 2012050100360 support@can -->
210</div>
211<div class="sponsor">
cristyba1758d2011-06-03 01:29:12 +0000212 <a rel="follow" title="Sponsor: Web Hosting Reviews" href="http://www.webhostingsecretrevealed.com">Web Hosting Secret Revealed</a><!-- 201204010540 iamchee jerry -->
213</div>
cristyeed6cb62012-01-28 19:38:34 +0000214<div class="sponsor">
cristyba1758d2011-06-03 01:29:12 +0000215 <a rel="follow" title="Sponsor: Druckerei" href="http://www.allesdruck.de">Druckerei</a><!-- 201303011500 r.leo -->
216</div>
cristyeed6cb62012-01-28 19:38:34 +0000217<div class="sponsor">
218 <a rel="follow" title="Sponsor: Turbolader Online kaufen" href="http://www.autoteile-carparts.de">Turbolader Online kaufen</a><!-- 2012050100150 t.temurbas...-->
cristyba1758d2011-06-03 01:29:12 +0000219</div>
cristyeed6cb62012-01-28 19:38:34 +0000220<div class="sponsor">
221 <a rel="follow" title="Sponsor: Web Hosting Reviews" href="http://www.webhostingreviewz.com">Web Hosting Reviews</a><!-- 2012040100030 Soft Tec-->
cristyba1758d2011-06-03 01:29:12 +0000222</div>
223</div>
224</div>
225</div>
226
227<div class="eastbar">
cristy29c5c992011-06-25 13:58:49 +0000228 <div class="g-plusone" data-size="standard" data-count="false"></div>
cristyeed6cb62012-01-28 19:38:34 +0000229 <script type="text/javascript">
230 window.___gcfg = {
231 lang: 'en-US'
232 };
233
234 (function() {
235 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
236 po.src = 'https://apis.google.com/js/plusone.js';
237 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
238 })();
239 </script>
cristy29c5c992011-06-25 13:58:49 +0000240</div>
cristyba1758d2011-06-03 01:29:12 +0000241
242<div class="main">
243
cristyba1758d2011-06-03 01:29:12 +0000244<h1>ImageMagick Version 7 Porting Guide</h1>
245
cristyeed6cb62012-01-28 19:38:34 +0000246<p class="navigation-index">[<a href="#imv7">ImageMagick Version 7</a> &bull; <a href="#channels">Pixel Channels</a> &bull; <a href="#alpha">Alpha</a> &bull; <a href="#grayscale">Grayscale</a> &bull; <a href="#core">MagickCore API Changes</a> &bull; <a href="#headers">Header Files</a> &bull; <a href="#depecate">Deprecated Features Removed</a> &bull; <a href="#cli">Command-line Interface</a> &bull; <a href="#summary">Version 7 Change Summary</a> ]</p>
cristyba1758d2011-06-03 01:29:12 +0000247
cristyeed6cb62012-01-28 19:38:34 +0000248<h2><a id="imv7"></a>ImageMagick Version 7</h2>
249<div class="doc-section">
cristy1efc1ab2011-08-01 14:47:02 +0000250<p>The design of ImageMagick is an evolutionary process, with the design and implementation efforts serving to influence and guide further progress in the other. With ImageMagick version 7 we aim to improve the design based on lessons learned from the version 6 implementation. ImageMagick was originally designed to display RGB images to an X Windows server. Over time we extended support to RGBA images and then to the CMYK and CMYKA image format. With ImageMagick version 7, we extend support to arbitrary colorspaces with an arbitrary number of pixel channels. Other design changes are in the works and we will document them here so be sure to revisit periodically.</p>
cristy29c5c992011-06-25 13:58:49 +0000251
cristyeed6cb62012-01-28 19:38:34 +0000252<p>To support variable pixel channels in the MagickCore API, pixel handling has changed when getting or setting the pixel channels. You can access channels as an array, <em>pixel[i]</em>, or use an accessor such as GetPixelRed() or SetPixelRed(). There are some modest changes to the MagickWand API. Magick++ and PerlMagick should behave exactly as it does for ImageMagick version 6.</p>
cristy29c5c992011-06-25 13:58:49 +0000253
cristyeed6cb62012-01-28 19:38:34 +0000254<p>We intend to make ImageMagick version 7 available as an Alpha release by the mid-year 2012. Look for a Beta release sometime in late 2012. An official ImageMagick version 7 release depends on how smoothly the Beta cycle progresses. During the Beta cycle, version 6 developers can attempt to port their software to version 7.<p>
cristy29c5c992011-06-25 13:58:49 +0000255
256<p>During the ImageMagick version 7 development cycle and release, we will continue to support and enhance version 6 for a minimum of 10 years.</p>
cristyba1758d2011-06-03 01:29:12 +0000257</div>
258
cristy1efc1ab2011-08-01 14:47:02 +0000259<h2><a id="channels"></a>Pixel Channels</h2>
cristyba1758d2011-06-03 01:29:12 +0000260<div class="doc-section">
cristy1efc1ab2011-08-01 14:47:02 +0000261<p>A pixel is comprised of one or more color values, or <em>channels</em> (e.g. red pixel channel).</p>
262<p>Prior versions of ImageMagick (4-6), support 4 to 5 pixel channels (RGBA or CMYKA). The first 4 channels are accessed with the PixelPacket data structure. The structure includes 4 members of type Quantum (typically 16-bits) of red, green, blue, and opacity. The black channel or colormap indexes are supported by a separate method and structure, IndexPacket. As an example, here is a code snippet from ImageMagick version 6 that negates the color components (but not the alpha component) of the image pixels:</p>
cristyba1758d2011-06-03 01:29:12 +0000263
264<pre class="code">
265 for (y=0; y &lt; (ssize_t) image->rows; y++)
266 {
267 register IndexPacket
268 *indexes;
269
270 register PixelPacket
271 *q;
272
273 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
274 if (q == (PixelPacket *) NULL)
275 {
276 status=MagickFalse;
277 continue;
278 }
279 indexes=GetCacheViewAuthenticIndexQueue(image_view);
280 for (x=0; x &lt; (ssize_t) image->columns; x++)
281 {
cristya4dfb122011-07-07 19:01:57 +0000282 if ((channel & RedChannel) != 0)
cristyba1758d2011-06-03 01:29:12 +0000283 q->red=(Quantum) QuantumRange-q->red;
cristya4dfb122011-07-07 19:01:57 +0000284 if ((channel & GreenChannel) != 0)
cristyba1758d2011-06-03 01:29:12 +0000285 q->green=(Quantum) QuantumRange-q->green;
cristya4dfb122011-07-07 19:01:57 +0000286 if ((channel & BlueChannel) != 0)
cristyba1758d2011-06-03 01:29:12 +0000287 q->blue=(Quantum) QuantumRange-q->blue;
cristya4dfb122011-07-07 19:01:57 +0000288 if (((channel & IndexChannel) != 0) &&
cristyba1758d2011-06-03 01:29:12 +0000289 (image->colorspace == CMYKColorspace))
290 indexes[x]=(IndexPacket) QuantumRange-indexes[x];
291 q++;
292 }
293 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
294 status=MagickFalse;
295 }
296</pre>
297
cristyeed6cb62012-01-28 19:38:34 +0000298<p>ImageMagick version 7 supports any number of channels from 1 to 32 (and beyond) and simplifies access with a single method that returns an array of pixel channels of type Quantum. Source code that compiles against prior versions of ImageMagick requires refactoring to work with ImageMagick version 7. We illustrate with an example. Let's naively refactor the version 6 code snippet from above so it works with the ImageMagick version 7 API:</p>
cristyba1758d2011-06-03 01:29:12 +0000299
300<pre class="code">
301 for (y=0; y &lt; (ssize_t) image->rows; y++)
302 {
303 register Quantum
304 *q;
305
306 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
307 if (q == (Quantum *) NULL)
308 {
309 status=MagickFalse;
310 continue;
311 }
312 for (x=0; x &lt; (ssize_t) image->columns; x++)
cristy29c5c992011-06-25 13:58:49 +0000313 {
cristy1efc1ab2011-08-01 14:47:02 +0000314 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
cristy29c5c992011-06-25 13:58:49 +0000315 SetPixelRed(image,QuantumRange-GetPixelRed(image,q),q);
cristy1efc1ab2011-08-01 14:47:02 +0000316 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
cristy29c5c992011-06-25 13:58:49 +0000317 SetPixelGreen(image,QuantumRange-GetPixelGreen(image,q),q);
cristy1efc1ab2011-08-01 14:47:02 +0000318 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
cristy29c5c992011-06-25 13:58:49 +0000319 SetPixelBlue(image,QuantumRange-GetPixelBlue(image,q),q);
cristy1efc1ab2011-08-01 14:47:02 +0000320 if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
cristy29c5c992011-06-25 13:58:49 +0000321 SetPixelBlack(image,QuantumRange-GetPixelBlack(image,q),q);
cristy1efc1ab2011-08-01 14:47:02 +0000322 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
cristy29c5c992011-06-25 13:58:49 +0000323 SetPixelAlpha(image,QuantumRange-GetPixelAlpha(image,q),q);
cristy1efc1ab2011-08-01 14:47:02 +0000324 q+=GetPixelChannels(image);
cristy29c5c992011-06-25 13:58:49 +0000325 }
326 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
327 status=MagickFalse;
328 }
329</pre>
330
cristy1efc1ab2011-08-01 14:47:02 +0000331<p>Let's do that again but take full advantage of the new variable pixel channel support:</p>
cristy29c5c992011-06-25 13:58:49 +0000332<pre class="code">
333 for (y=0; y &lt; (ssize_t) image->rows; y++)
334 {
335 register Quantum
336 *q;
337
338 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
339 if (q == (Quantum *) NULL)
340 {
341 status=MagickFalse;
342 continue;
343 }
344 for (x=0; x &lt; (ssize_t) image->columns; x++)
cristy1efc1ab2011-08-01 14:47:02 +0000345 {
346 register ssize_t
347 i;
348
349 for (i=0; i &lt; (ssize_t) GetPixelChannels(image); i++)
cristyba1758d2011-06-03 01:29:12 +0000350 {
cristyeed6cb62012-01-28 19:38:34 +0000351 PixelChannel
352 channel;
353
cristy1efc1ab2011-08-01 14:47:02 +0000354 PixelTrait
355 traits;
356
cristyeed6cb62012-01-28 19:38:34 +0000357 channel=GetPixelChannelMapChannel(image,i);
358 traits=GetPixelChannelMapTraits(image,channel);
cristy1efc1ab2011-08-01 14:47:02 +0000359 if ((traits &amp; UpdatePixelTrait) != 0)
360 q[i]=QuantumRange-q[i];
cristyba1758d2011-06-03 01:29:12 +0000361 }
cristy1efc1ab2011-08-01 14:47:02 +0000362 q+=GetPixelChannels(image);
363 }
cristyba1758d2011-06-03 01:29:12 +0000364 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
365 status=MagickFalse;
366 }
367</pre>
368
cristyeed6cb62012-01-28 19:38:34 +0000369<p>Note, how we use GetPixelChannels() to advance to the next set of pixel channels.</p>
cristye6e84152011-06-06 14:16:49 +0000370
cristyeed6cb62012-01-28 19:38:34 +0000371<p>The colormap indexes and black pixel channel (for the CMYK colorspace) are no longer stored in the index channel, previously accessed with GetAuthenticIndexQueue() and GetCacheViewAuthenticIndexQueue((). Instead they are now a pixel channel and accessed with the convenience pixel accessor methods GetPixelIndex(), SetPixelIndex(), GetPixelBlack(), and SetPixelBlack().</p>
cristy29c5c992011-06-25 13:58:49 +0000372
cristy87a7f072011-07-01 00:08:52 +0000373<h4></a>Pixel Accessors</h4>
cristy1efc1ab2011-08-01 14:47:02 +0000374<p>Use accessors to get or set pixel channels:</p>
cristy87a7f072011-07-01 00:08:52 +0000375
376<pre class="text">
377 GetPixelAlpha()
378 GetPixelBlack()
379 GetPixelBlue()
380 GetPixelCb()
cristy1efc1ab2011-08-01 14:47:02 +0000381 GetPixelChannels()
cristy87a7f072011-07-01 00:08:52 +0000382 GetPixelCr()
383 GetPixelCyan()
384 GetPixelGray()
385 GetPixelGreen()
386 GetPixelIndex()
387 GetPixelInfoIntensity()
388 GetPixelInfoLuminance()
389 GetPixelMagenta()
390 GetPixelRed()
391 GetPixelPacket()
392 GetPixelPacketIntensity()
393 GetPixelY()
394 GetPixelYellow()
395 GetPixelIntensity()
396 SetPixelAlpha()
397 SetPixelBlack()
398 SetPixelBlue()
399 SetPixelCb()
cristy1efc1ab2011-08-01 14:47:02 +0000400 SetPixelChannels()
cristy87a7f072011-07-01 00:08:52 +0000401 SetPixelCr()
402 SetPixelCyan()
403 SetPixelGray()
404 SetPixelGreen()
405 SetPixelIndex()
406 SetPixelInfo()
407 SetPixelInfoBias()
408 SetPixelInfoPacket()
409 SetPixelMagenta()
410 SetPixelRed()
411 SetPixelPacket()
412 SetPixelPixelInfo()
413 SetPixelYellow()
414 SetPixelY()
415</pre>
416
417<p>You can find these accessors defined in the header file, <kbd>MagickCore/pixel-accessor.h</kbd></p>
418
cristya4dfb122011-07-07 19:01:57 +0000419<h4></a>Pixel Traits</h4>
cristy1efc1ab2011-08-01 14:47:02 +0000420<p>Each pixel channel includes one or more of these traits:</p>
cristya4dfb122011-07-07 19:01:57 +0000421<dl>
422<dt>Undefined</dt>
cristy1efc1ab2011-08-01 14:47:02 +0000423<dd>no traits associated with this pixel channel<dd>
424<dt>Copy</dt>
425<dd>do not update this pixel channel, just copy it<dd>
426<dt>Update</dt>
427<dd>update this pixel channel<dd>
cristya4dfb122011-07-07 19:01:57 +0000428<dt>Blend</dt>
cristy1efc1ab2011-08-01 14:47:02 +0000429<dd>blend this pixel channel with the alpha mask if it's enabled<dd>
cristya4dfb122011-07-07 19:01:57 +0000430</dl>
431<p>We provide these methods to set and get pixel traits:</p>
432<pre class="text">
433 GetPixelAlphaTraits()
434 GetPixelBlackTraits()
435 GetPixelBlueTraits()
436 GetPixelCbTraits()
437 GetPixelCrTraits()
438 GetPixelCyanTraits()
439 GetPixelGrayTraits()
440 GetPixelGreenTraits()
441 GetPixelIndexTraits()
442 GetPixelMagentaTraits()
443 GetPixelRedTraits()
cristy1efc1ab2011-08-01 14:47:02 +0000444 GetPixelChannelTraits()
cristya4dfb122011-07-07 19:01:57 +0000445 GetPixelYTraits()
446 GetPixelYellowTraits()
447 SetPixelAlphaTraits()
448 SetPixelBlackTraits()
449 SetPixelBlueTraits()
450 SetPixelCbTraits()
cristy1efc1ab2011-08-01 14:47:02 +0000451 SetPixelChannelTraits()
cristya4dfb122011-07-07 19:01:57 +0000452 SetPixelCrTraits()
453 SetPixelGrayTraits()
454 SetPixelGreenTraits()
455 SetPixelIndexTraits()
456 SetPixelMagentaTraits()
457 SetPixelRedTraits()
458 SetPixelYellowTraits()
459 SetPixelYTraits()
460</pre>
cristy1efc1ab2011-08-01 14:47:02 +0000461<p>For convenience you can set the active trait for a set of pixel channels with a channel mask and these methods:</p>
cristya4dfb122011-07-07 19:01:57 +0000462<pre class="text">
cristy1efc1ab2011-08-01 14:47:02 +0000463 PopPixelChannelMap()
cristy1efc1ab2011-08-01 14:47:02 +0000464 SetPixelChannelMap()
cristyeed6cb62012-01-28 19:38:34 +0000465 SetPixelChannelMask()
cristya4dfb122011-07-07 19:01:57 +0000466</pre>
467
cristy1efc1ab2011-08-01 14:47:02 +0000468<p>Previously MagickCore methods had channel analogs, for example, NegateImage() and NegateImageChannels(). The channel analog methods are no longer necessary because the pixel channel traits specify whether to act on a particular pixel channel and whether to blend with the alpha mask. For example, instead of</p>
cristya4dfb122011-07-07 19:01:57 +0000469<pre class="text">
470 NegateImageChannel(image,channel);
471</pre>
472<p>we use:</p>
473<pre class="text">
cristyeed6cb62012-01-28 19:38:34 +0000474 channel_mask=SetPixelChannelMask(image,channel);
475 NegateImage(image,exception);
476 (void) SetPixelChannelMap(image,channel_mask);
cristya4dfb122011-07-07 19:01:57 +0000477</pre>
478
cristyeed6cb62012-01-28 19:38:34 +0000479<h4></a>Pixel User Channels</h4>
480<p>In version 7, we introduce pixel user channels. Traditionally we utilize 4 channels, red, green, blue, and alpha. For CMYK we also have a black channel. User channels are designed to contain whatever additional channel information that makes sense for your application. Some examples include extra channels in TIFF or PSD images or perhaps you require a channel with infrared information for the pixel. You can associate traits with the user channels so that they when they are acted upon by an image processing algorithm (e.g. blur) the pixels are copied, acted upon by the algorithm, or even blended with the alpha channel if that makes sense.</p>
cristy87a7f072011-07-01 00:08:52 +0000481<h4></a>Pixel Metacontent</h4>
cristyeed6cb62012-01-28 19:38:34 +0000482<p>In version 7, we introduce pixel metacontent. Metacontent is content about content. So rather than being the content itself, it's something that describes or is associated with the content. Here the content is a pixel. The pixel metacontent is for your exclusive use and is accessed with these MagickCore API methods:</p>
cristy87a7f072011-07-01 00:08:52 +0000483<pre class="text">
484 SetImageMetacontentExtent()
485 GetImageMetacontentExtent()
486 GetVirtualMetacontent()
487 GetAuthenticMetacontent()
488 GetCacheViewAuthenticMetacontent()
489 GetCacheViewVirtualMetacontent()
490</pre>
cristyba1758d2011-06-03 01:29:12 +0000491</div>
492
493<h2><a id="alpha"></a>Alpha</h2>
494<div class="doc-section">
cristyeed6cb62012-01-28 19:38:34 +0000495<p>We support alpha now, previously opacity. With alpha, a value of 0 means that the pixel does not have any coverage information and is transparent; i.e. there was no color contribution from any geometry because the geometry did not overlap this pixel. A value of QuantumRange means that the pixel is opaque because the geometry completely overlapped the pixel. As a consequence, in version 7, the PixelInfo structure member alpha has replaced the previous opacity member.</p>
cristyba1758d2011-06-03 01:29:12 +0000496</div>
cristy87a7f072011-07-01 00:08:52 +0000497<h2><a id="grayscale"></a>Grayscale</h2>
498<div class="doc-section">
cristy1efc1ab2011-08-01 14:47:02 +0000499<p>Previously, grayscale images consumed 4 channels: red, green, blue, and alpha. With version 7, grayscale consumes only 1 channel consuming far less resources as a result. However, there may be unintended consequences. With 1 channel, all image processing algorithms write to this one channel. Drawing yellow text on a grayscale image will produce gray lettering. To get the expected results, simply modify the colorspace to RGB (e.g. -colorspace rgb).</p>
cristy87a7f072011-07-01 00:08:52 +0000500</div>
cristyba1758d2011-06-03 01:29:12 +0000501
cristy1efc1ab2011-08-01 14:47:02 +0000502<h2><a id="core"></a>MagickCore API Changes</h2>
503<div class="doc-section">
cristyeed6cb62012-01-28 19:38:34 +0000504<p>Almost all image processing algorithms are now channel aware.</p>
cristy1efc1ab2011-08-01 14:47:02 +0000505<p>MagickCore, version 7, adds an ExceptionInfo argument to those methods that lacked it in version 6, e.g. NegateImage(image,MagickTrue,exception);</p>
506<p>All method channel analogs have been removed (e.g. BlurImageChannel()), they are no longer necessary, use pixel traits instead.</p>
cristyeed6cb62012-01-28 19:38:34 +0000507<p>Public and private API calls are now declared with the GCC visibility attribute. The MagickCore and MagickWand dynamic libraries now only export public struct and function declarations.</p>
508<p>The InterpolatePixelMethod enum is now PixelInterpolateMethod.</p>
509<p>The IntegerPixel storage type is removed (use LongPixel instead) and LongLongPixel is added</p>
510<p>Image signatures have changed to account for variable pixel channels.</p>
511<p>All color packet structures, PixelPacket, LongPacket, and DoublePacket, are consolidated to a single color structure, PixelInfo.</p>
512</div>
513<h2><a id="headers"></a>Header Files</h2>
514<div class="doc-section">
515<p>Prior versions of ImageMagick (4-6) reference the ImageMagick header files as <kbd>magick/</kbd> and <kbd>wand/</kbd>. ImageMagick 7 instead uses <kbd>MagickCore/</kbd> and <kbd>MagickWand/</kbd> respectively. For example,</p>
516<pre class="code">
517#include &lt;MagickCore/MagickCore.h>
518#include &lt;MagickWand/MagickWand.h>
519</pre>
cristy1efc1ab2011-08-01 14:47:02 +0000520</div>
cristyba1758d2011-06-03 01:29:12 +0000521<h2><a id="deprecate"></a>Deprecated Features Removed</h2>
522<div class="doc-section">
cristye6e84152011-06-06 14:16:49 +0000523<p>All deprecated features from ImageMagick version 6 are removed in version 7. These include the <kbd>Magick-config</kbd> and <kbd>Wand-config</kbd> configuration utilities. Instead use:</p>
cristyba1758d2011-06-03 01:29:12 +0000524
525<pre class="code">
526 MagickCore-config
527 MagickWand-config
528</pre>
cristyeed6cb62012-01-28 19:38:34 +0000529<p>The FilterImage() method has been removed. Use ConvolveImage() instead.</p>
cristyba1758d2011-06-03 01:29:12 +0000530
531<p>In addition, all deprecated <a href="http://magick.imagemagick.org/api/deprecate.html">MagickCore</a> and <a href="http://magick.imagemagick.org/api/magick-deprecate.html">MagickWand</a> methods are no longer available in version 7.</p>
cristy1efc1ab2011-08-01 14:47:02 +0000532</div>
533<h2><a id="cli"></a>Command-line Interface</h2>
534<div class="doc-section">
535<p>By default, most algorithms update the red, green, blue, black (for CMYK), and alpha channels. If appropriate, alpha is blended with red, green, blue, and black. For some algorithms, it only makes sense to copy alpha. For these cases, use the -channel option (e.g. convert castle.gif -channel RGB -negate castle.png).</p>
536<p>The <kbd>-convolve</kbd> option no longer normalizes the kernel argument and accepts non-square <a href="http://www.imagemagick.org/Usage/morphology/#user">user defined kernels</a>.</p>
cristyba1758d2011-06-03 01:29:12 +0000537</div>
538<h2><a id="summary"></a>Version 7 Change Summary</h2>
539<div class="doc-section">
cristye6e84152011-06-06 14:16:49 +0000540<p>Changes from ImageMagick version 6 to version 7 are summarized here:</p>
cristyba1758d2011-06-03 01:29:12 +0000541<h5>Pixels</h5>
542<dl>
cristy1efc1ab2011-08-01 14:47:02 +0000543<li>Pixels are no longer addressed with PixelPacket structure members (e.g. red, green, blue, opacity) but as an array of channels (e.g. pixel[PixelRedChannel]).</li>
544<li>Use convenience macros to access pixel channels (e.g. GetPixelRed(), SetPixelRed()).</li>
545<li>The black channel for the CMYK colorspace is no longer stored in the index channel, previously accessed with GetAuthenticIndexQueue() and GetCacheViewAuthenticIndexQueue((). Instead it is now a pixel channel and accessed with the convenience pixel macros GetPixelBlack() and SetPixelBlack().</li>
546<li>The index channel for colormapped images is no longer stored in the index channel, previously accessed with GetAuthenticIndexQueue() and GetCacheViewAuthenticIndexQueue((). Instead it is now a pixel channel and accessed with the convenience pixel macros GetPixelIndex() and SetPixelIndex().</li>
547<li>Use GetPixelChannels() to advance to the next set of pixel channels.</li>
548<li>Use the <em>metacontent</em> channel to associate metacontent with each pixel.</li>
cristyeed6cb62012-01-28 19:38:34 +0000549<li>All color packet structures, PixelPacket, LongPacket, and DoublePacket, are consolidated to a single color structure, PixelInfo.</li>
cristyba1758d2011-06-03 01:29:12 +0000550</dl>
551<h5>Alpha</h5>
552<dl>
553<li>We support alpha rather than opacity (0 transparent; QuantumRange opaque).</li>
cristy1efc1ab2011-08-01 14:47:02 +0000554<li>Use GetPixelAlpha() or SetPixelAlpha() to get or set the alpha pixel channel value.</li>
cristyba1758d2011-06-03 01:29:12 +0000555</dl>
cristy87a7f072011-07-01 00:08:52 +0000556<h5>Grayscale</h5>
557<dl>
cristy1efc1ab2011-08-01 14:47:02 +0000558<li>Grayscale images consume one pixel channel in ImageMagick version 7. To process RGB, set the colorspace to RGB (e.g. -colorspace rgb).</li>
559</dl>
560<h5>MagickCore API Changes</h5>
561<dl>
cristyeed6cb62012-01-28 19:38:34 +0000562<li>Almost all image processing algorithms are now channel aware.</li>
cristy1efc1ab2011-08-01 14:47:02 +0000563<li>MagickCore, version 7, adds an ExceptionInfo argument to those methods that lacked it in version 6, e.g. NegateImage(image,MagickTrue,exception);</li>
564<li>All method channel analogs have been removed (e.g. BlurImageChannel()), they are no longer necessary, use pixel traits instead.</li>
cristyeed6cb62012-01-28 19:38:34 +0000565<li>Public and private API calls are now declared with the GCC visibility attribute. The MagickCore and MagickWand dynamic libraries now only export public struct and function declarations.</li>
566<li>The InterpolatePixelMethod enum is now PixelInterpolateMethod.</li>
567<li>To account for variable pixel channels, images may now return a different signature.</li>
cristy87a7f072011-07-01 00:08:52 +0000568</dl>
cristyba1758d2011-06-03 01:29:12 +0000569<h5>Deprecated Methods</h5>
570<dl>
cristy2dcd6822011-06-13 16:21:20 +0000571<li>All ImageMagick version 6 MagickCore and MagickWand deprecated methods are removed and no longer available in ImageMagick version 7.</li>
cristya4dfb122011-07-07 19:01:57 +0000572<li>All MagickCore channel method analogs are removed (e.g. NegateImageChannels()). For version 7, use pixel traits instead.</li>
cristy1efc1ab2011-08-01 14:47:02 +0000573<li>The FilterImage() method has been removed. Use ConvolveImage() instead.</li>
574<h5>Command-line Interface</h5>
575<dl>
576<li>If you don't want alpha negated, use the -channel option, e.g. convert castle.gif -channel RGB -negate castle.png.</li>
577<li>The <kbd>-convolve</kbd> option no longer normalizes the kernel argument and accepts non-square <a href="http://www.imagemagick.org/Usage/morphology/#user">user defined kernels</a>.</li>
578</dl>
cristyba1758d2011-06-03 01:29:12 +0000579</dl>
580</div>
581
582</div>
583
584<div id="linkbar">
585 <span id="linkbar-west">&nbsp;</span>
586 <span id="linkbar-center">
587 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
588 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
589 </span>
590 <span id="linkbar-east">&nbsp;</span>
591 </div>
592 <div class="footer">
cristyeed6cb62012-01-28 19:38:34 +0000593 <span id="footer-west">&copy; 1999-2011 ImageMagick Studio LLC</span>
cristyba1758d2011-06-03 01:29:12 +0000594 <span id="footer-east"> <a href="http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
595 </div>
596 <div style="clear: both; margin: 0; width: 100%; "></div>
597 <script type="text/javascript">
598 var _gaq = _gaq || [];
599 _gaq.push(['_setAccount', 'UA-17690367-1']);
600 _gaq.push(['_trackPageview']);
601
602 (function() {
603 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
604 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
605 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
606 })();
607 </script>
608</body>
609</html>