Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 1 | |
| 2 | |
| 3 | |
| 4 | |
cristy | 29dc865 | 2015-05-12 16:26:21 +0000 | [diff] [blame] | 5 | <!DOCTYPE html> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 6 | <html lang="en"> |
cristy | ad41c0c | 2012-10-31 00:49:28 +0000 | [diff] [blame] | 7 | <head> |
Cristy | 912a922 | 2016-06-17 15:37:28 -0400 | [diff] [blame] | 8 | <meta charset="utf-8" /> |
Cristy | 3b0b58d | 2016-11-06 07:40:23 -0500 | [diff] [blame] | 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" /> |
Cristy | bc23242 | 2016-11-22 07:46:18 -0500 | [diff] [blame] | 11 | <title>MagickWand, C API @ ImageMagick</title> |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 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."/> |
Cristy | 364a72f | 2016-11-04 22:38:41 -0400 | [diff] [blame] | 15 | <meta name="application-url" content="https://www.imagemagick.org"/> |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 16 | <meta name="generator" content="PHP"/> |
Cristy | bc23242 | 2016-11-22 07:46:18 -0500 | [diff] [blame] | 17 | <meta name="keywords" content="magickwc, api, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/> |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 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"/> |
Cristy | fe36f99 | 2016-12-29 20:24:13 -0500 | [diff] [blame] | 24 | <meta name="copyright" content="Copyright (c) 1999-2017 ImageMagick Studio LLC"/> |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 25 | <meta name="distribution" content="Global"/> |
| 26 | <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/> |
Cristy | 912a922 | 2016-06-17 15:37:28 -0400 | [diff] [blame] | 27 | <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" /> |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 28 | <link rel="canonical" href="https://www.imagemagick.org/script/magick-wand.html"/> |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 29 | <link rel="icon" href="../images/wand.png"/> |
| 30 | <link rel="shortcut icon" href="../images/wand.ico"/> |
Cristy | bc23242 | 2016-11-22 07:46:18 -0500 | [diff] [blame] | 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" /> |
Cristy | ce4a355 | 2015-12-14 13:53:35 -0500 | [diff] [blame] | 32 | <link rel="stylesheet" href="css/magick.css"/> |
cristy | ad41c0c | 2012-10-31 00:49:28 +0000 | [diff] [blame] | 33 | </head> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 34 | <body> |
cristy | ad41c0c | 2012-10-31 00:49:28 +0000 | [diff] [blame] | 35 | <div class="main"> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 36 | <div class="magick-masthead"> |
| 37 | <div class="container"> |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 38 | <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 39 | style="display:block" |
| 40 | data-ad-client="ca-pub-3129977114552745" |
| 41 | data-ad-slot="6345125851" |
| 42 | data-ad-format="auto"></ins> |
cristy | 29f2c97 | 2015-07-28 13:37:46 +0000 | [diff] [blame] | 43 | <script> |
Cristy | 542697a | 2015-10-12 20:10:32 -0400 | [diff] [blame] | 44 | (adsbygoogle = window.adsbygoogle || []).push({}); |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 45 | </script> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 46 | <nav class="magick-nav"> |
cristy | 44443b9 | 2015-05-05 00:06:07 +0000 | [diff] [blame] | 47 | <a class="magick-nav-item " href="../index.html">Home</a> |
Cristy | 9017f3a | 2017-01-21 10:51:11 -0500 | [diff] [blame] | 48 | <a class="magick-nav-item " href="download.html">Download</a> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 49 | <a class="magick-nav-item " href="command-line-tools.html">Tools</a> |
Cristy | e93be68 | 2015-11-26 09:07:51 -0500 | [diff] [blame] | 50 | <a class="magick-nav-item " href="command-line-processing.html">Command-line</a> |
cristy | ea2793e | 2015-05-31 16:52:26 +0000 | [diff] [blame] | 51 | <a class="magick-nav-item " href="resources.html">Resources</a> |
Cristy | 9017f3a | 2017-01-21 10:51:11 -0500 | [diff] [blame] | 52 | <a class="magick-nav-item " href="develop.html">Develop</a> |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 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> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 55 | </nav> |
| 56 | </div> |
| 57 | </div> |
| 58 | <div class="container"> |
| 59 | <div class="magick-header"> |
cristy | ad41c0c | 2012-10-31 00:49:28 +0000 | [diff] [blame] | 60 | |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 61 | <p class="lead magick-description">The <a href="http://www.imagemagick.org/api/MagickWand/index.html">MagickWand API</a> is the recommended interface between the C programming language and the ImageMagick image processing libraries. Unlike the <a href="magick-core.html">MagickCore</a> C API, MagickWand uses only a few opaque types. Accessors are available to set or get important wand properties. A description of the MagickWand public methods are found here:</p> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 62 | |
| 63 | <ul> |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 64 | <li><a href="http://www.imagemagick.org/api/magick-wand.html">Magick Wand Methods</a></li> |
| 65 | <li><a href="http://www.imagemagick.org/api/magick-property.html">Set or Get Magick Wand Properties</a></li> |
| 66 | <li><a href="http://www.imagemagick.org/api/magick-image.html">Magick Wand Image Methods</a></li> |
| 67 | <li><a href="http://www.imagemagick.org/api/pixel-iterator.html">Pixel Iterator Methods</a></li> |
| 68 | <li><a href="http://www.imagemagick.org/api/pixel-wand.html">Pixel Wand Methods</a></li> |
| 69 | <li><a href="http://www.imagemagick.org/api/drawing-wand.html">Image Vector Drawing</a></li> |
| 70 | <li><a href="http://www.imagemagick.org/api/mogrify.html">Command-line Interface</a></li> |
cristy | 10d5f99 | 2015-05-07 17:52:30 +0000 | [diff] [blame] | 71 | <li><a href="api/wand-view.html">Wand View Methods</a></li> |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 72 | <li><a href="http://www.imagemagick.org/api/magick-deprecate.html">Deprecated Methods</a></li> |
cristy | 751980d | 2012-06-03 23:18:35 +0000 | [diff] [blame] | 73 | <li><a href="exception.html">Error and Warning Codes</a></li> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 74 | </ul> |
| 75 | |
| 76 | <p>After you write your MagickWand program, compile it like this:</p> |
| 77 | |
cristy | 82a2ff2 | 2015-05-12 16:41:32 +0000 | [diff] [blame] | 78 | <pre> |
| 79 | cc -o wand wand.c `pkg-config --cflags --libs MagickWand` |
| 80 | </pre> |
| 81 | |
cristy | 8ee7f24 | 2013-06-20 16:08:44 +0000 | [diff] [blame] | 82 | <p>Set the <code>PKG_CONFIG_PATH</code> environment variable if ImageMagick is not in your default system path:</p> |
cristy | 82a2ff2 | 2015-05-12 16:41:32 +0000 | [diff] [blame] | 83 | |
| 84 | <pre> |
| 85 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig |
| 86 | </pre> |
| 87 | |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 88 | <p>Here is a example program that utilizes the MagickWand API to get you started, <a href="http://www.imagemagick.org/source/wand.c">wand.c</a>. It reads an image, creates a thumbnail, and writes the result to disk.</p> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 89 | |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 90 | <pre class="pre-scrollable">#include <stdio.h> |
| 91 | #include <stdlib.h> |
| 92 | #include <wand/MagickWand.h> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 93 | |
| 94 | int main(int argc,char **argv) |
| 95 | { |
| 96 | #define ThrowWandException(wand) \ |
| 97 | { \ |
| 98 | char \ |
| 99 | *description; \ |
| 100 | \ |
| 101 | ExceptionType \ |
| 102 | severity; \ |
| 103 | \ |
| 104 | description=MagickGetException(wand,&severity); \ |
cristy | acc0488 | 2011-05-04 23:03:43 +0000 | [diff] [blame] | 105 | (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 106 | description=(char *) MagickRelinquishMemory(description); \ |
| 107 | exit(-1); \ |
| 108 | } |
| 109 | |
| 110 | MagickBooleanType |
| 111 | status; |
| 112 | |
| 113 | MagickWand |
| 114 | *magick_wand; |
| 115 | |
| 116 | if (argc != 3) |
| 117 | { |
| 118 | (void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]); |
| 119 | exit(0); |
| 120 | } |
| 121 | /* |
| 122 | Read an image. |
| 123 | */ |
| 124 | MagickWandGenesis(); |
| 125 | magick_wand=NewMagickWand(); |
| 126 | status=MagickReadImage(magick_wand,argv[1]); |
| 127 | if (status == MagickFalse) |
| 128 | ThrowWandException(magick_wand); |
| 129 | /* |
| 130 | Turn the images into a thumbnail sequence. |
| 131 | */ |
| 132 | MagickResetIterator(magick_wand); |
| 133 | while (MagickNextImage(magick_wand) != MagickFalse) |
| 134 | MagickResizeImage(magick_wand,106,80,LanczosFilter,1.0); |
| 135 | /* |
| 136 | Write the image then destroy it. |
| 137 | */ |
| 138 | status=MagickWriteImages(magick_wand,argv[2],MagickTrue); |
| 139 | if (status == MagickFalse) |
| 140 | ThrowWandException(magick_wand); |
| 141 | magick_wand=DestroyMagickWand(magick_wand); |
| 142 | MagickWandTerminus(); |
| 143 | return(0); |
| 144 | } |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 145 | </pre> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 146 | |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 147 | <p>Here is another program that shows one way to get and set image pixels with the MagickWand API, <a href="http://www.imagemagick.org/source/contrast.c">contrast.c</a>. It reads an image, applies sigmoidal non-linearity contrast control, and writes the result to disk.</p> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 148 | |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 149 | <pre class="pre-scrollable">#include <stdio.h> |
| 150 | #include <stdlib.h> |
| 151 | #include <math.h> |
| 152 | #include <wand/MagickWand.h> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | |
| 154 | int main(int argc,char **argv) |
| 155 | { |
| 156 | #define QuantumScale ((MagickRealType) 1.0/(MagickRealType) QuantumRange) |
| 157 | #define SigmoidalContrast(x) \ |
| 158 | (QuantumRange*(1.0/(1+exp(10.0*(0.5-QuantumScale*x)))-0.0066928509)*1.0092503) |
| 159 | #define ThrowWandException(wand) \ |
| 160 | { \ |
| 161 | char \ |
| 162 | *description; \ |
| 163 | \ |
| 164 | ExceptionType \ |
| 165 | severity; \ |
| 166 | \ |
| 167 | description=MagickGetException(wand,&severity); \ |
| 168 | (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \ |
| 169 | description=(char *) MagickRelinquishMemory(description); \ |
| 170 | exit(-1); \ |
| 171 | } |
| 172 | |
| 173 | long |
| 174 | y; |
| 175 | |
| 176 | MagickBooleanType |
| 177 | status; |
| 178 | |
| 179 | MagickPixelPacket |
| 180 | pixel; |
| 181 | |
| 182 | MagickWand |
| 183 | *contrast_wand, |
| 184 | *image_wand; |
| 185 | |
| 186 | PixelIterator |
| 187 | *contrast_iterator, |
| 188 | *iterator; |
| 189 | |
| 190 | PixelWand |
| 191 | **contrast_pixels, |
| 192 | **pixels; |
| 193 | |
| 194 | register long |
| 195 | x; |
| 196 | |
| 197 | unsigned long |
| 198 | width; |
| 199 | |
| 200 | if (argc != 3) |
| 201 | { |
| 202 | (void) fprintf(stdout,"Usage: %s image sigmoidal-image\n",argv[0]); |
| 203 | exit(0); |
| 204 | } |
| 205 | /* |
| 206 | Read an image. |
| 207 | */ |
| 208 | MagickWandGenesis(); |
| 209 | image_wand=NewMagickWand(); |
| 210 | status=MagickReadImage(image_wand,argv[1]); |
| 211 | if (status == MagickFalse) |
| 212 | ThrowWandException(image_wand); |
| 213 | contrast_wand=CloneMagickWand(image_wand); |
| 214 | /* |
| 215 | Sigmoidal non-linearity contrast control. |
| 216 | */ |
| 217 | iterator=NewPixelIterator(image_wand); |
| 218 | contrast_iterator=NewPixelIterator(contrast_wand); |
| 219 | if ((iterator == (PixelIterator *) NULL) || |
| 220 | (contrast_iterator == (PixelIterator *) NULL)) |
| 221 | ThrowWandException(image_wand); |
| 222 | for (y=0; y < (long) MagickGetImageHeight(image_wand); y++) |
| 223 | { |
| 224 | pixels=PixelGetNextIteratorRow(iterator,&width); |
| 225 | contrast_pixels=PixelGetNextIteratorRow(contrast_iterator,&width); |
| 226 | if ((pixels == (PixelWand **) NULL) || |
| 227 | (contrast_pixels == (PixelWand **) NULL)) |
| 228 | break; |
| 229 | for (x=0; x < (long) width; x++) |
| 230 | { |
| 231 | PixelGetMagickColor(pixels[x],&pixel); |
| 232 | pixel.red=SigmoidalContrast(pixel.red); |
| 233 | pixel.green=SigmoidalContrast(pixel.green); |
| 234 | pixel.blue=SigmoidalContrast(pixel.blue); |
| 235 | pixel.index=SigmoidalContrast(pixel.index); |
| 236 | PixelSetMagickColor(contrast_pixels[x],&pixel); |
| 237 | } |
| 238 | (void) PixelSyncIterator(contrast_iterator); |
| 239 | } |
| 240 | if (y < (long) MagickGetImageHeight(image_wand)) |
| 241 | ThrowWandException(image_wand); |
| 242 | contrast_iterator=DestroyPixelIterator(contrast_iterator); |
| 243 | iterator=DestroyPixelIterator(iterator); |
| 244 | image_wand=DestroyMagickWand(image_wand); |
| 245 | /* |
| 246 | Write the image then destroy it. |
| 247 | */ |
| 248 | status=MagickWriteImages(contrast_wand,argv[2],MagickTrue); |
| 249 | if (status == MagickFalse) |
| 250 | ThrowWandException(image_wand); |
| 251 | contrast_wand=DestroyMagickWand(contrast_wand); |
| 252 | MagickWandTerminus(); |
| 253 | return(0); |
| 254 | } |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 255 | </pre> |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 256 | <p><a id="wand-view"></a>Now lets perform the same contrast enhancement while taking advantage of our dual or quad-core processing system by running the algorithm in parallel utilizing wand views. The <a href="http://www.imagemagick.org/source/wand/sigmoidal-contrast.c">sigmoidal-contrast.c</a> module reads an image, applies sigmoidal non-linearity contrast control, and writes the result to disk just like the previous contrast enhancement program, but now it does its work in parallel (assumes ImageMagick is built with OpenMP support).</p> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 257 | |
Cristy | 594d277 | 2015-11-15 10:47:42 -0500 | [diff] [blame] | 258 | <pre class="pre-scrollable">#include <stdio.h> |
| 259 | #include <stdlib.h> |
| 260 | #include <math.h> |
| 261 | #include <wand/MagickWand.h> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 262 | |
cristy | 10c8715 | 2010-06-26 16:12:21 +0000 | [diff] [blame] | 263 | static MagickBooleanType SigmoidalContrast(WandView *pixel_view, |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 264 | const ssize_t y,const int id,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 265 | { |
| 266 | #define QuantumScale ((MagickRealType) 1.0/(MagickRealType) QuantumRange) |
| 267 | #define SigmoidalContrast(x) \ |
| 268 | (QuantumRange*(1.0/(1+exp(10.0*(0.5-QuantumScale*x)))-0.0066928509)*1.0092503) |
| 269 | |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 270 | RectangleInfo |
| 271 | extent; |
| 272 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 273 | MagickPixelPacket |
| 274 | pixel; |
| 275 | |
| 276 | PixelWand |
| 277 | **pixels; |
| 278 | |
| 279 | register long |
| 280 | x; |
| 281 | |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 282 | extent=GetWandViewExtent(contrast_view); |
cristy | 10c8715 | 2010-06-26 16:12:21 +0000 | [diff] [blame] | 283 | pixels=GetWandViewPixels(contrast_view); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 284 | for (x=0; x < (long) (extent.width-extent.height); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 285 | { |
| 286 | PixelGetMagickColor(pixels[x],&pixel); |
| 287 | pixel.red=SigmoidalContrast(pixel.red); |
| 288 | pixel.green=SigmoidalContrast(pixel.green); |
| 289 | pixel.blue=SigmoidalContrast(pixel.blue); |
| 290 | pixel.index=SigmoidalContrast(pixel.index); |
| 291 | PixelSetMagickColor(contrast_pixels[x],&pixel); |
| 292 | } |
| 293 | return(MagickTrue); |
| 294 | } |
| 295 | |
| 296 | int main(int argc,char **argv) |
| 297 | { |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 298 | #define ThrowViewException(view) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 299 | { \ |
cristy | dcca3fa | 2010-12-29 21:50:07 +0000 | [diff] [blame] | 300 | description=GetWandViewException(view,&severity); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 301 | (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \ |
| 302 | description=(char *) MagickRelinquishMemory(description); \ |
| 303 | exit(-1); \ |
| 304 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 305 | #define ThrowWandException(wand) \ |
| 306 | { \ |
cristy | dcca3fa | 2010-12-29 21:50:07 +0000 | [diff] [blame] | 307 | description=MagickGetException(wand,&severity); \ |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 308 | (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \ |
| 309 | description=(char *) MagickRelinquishMemory(description); \ |
| 310 | exit(-1); \ |
| 311 | } |
| 312 | |
| 313 | char |
| 314 | *description; |
| 315 | |
| 316 | ExceptionType |
| 317 | severity; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 318 | |
| 319 | MagickBooleanType |
| 320 | status; |
| 321 | |
| 322 | MagickPixelPacket |
| 323 | pixel; |
| 324 | |
| 325 | MagickWand |
| 326 | *contrast_wand; |
| 327 | |
cristy | 10c8715 | 2010-06-26 16:12:21 +0000 | [diff] [blame] | 328 | WandView |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 329 | *contrast_view; |
| 330 | |
| 331 | if (argc != 3) |
| 332 | { |
| 333 | (void) fprintf(stdout,"Usage: %s image sigmoidal-image\n",argv[0]); |
| 334 | exit(0); |
| 335 | } |
| 336 | /* |
| 337 | Read an image. |
| 338 | */ |
| 339 | MagickWandGenesis(); |
| 340 | contrast_wand=NewMagickWand(); |
| 341 | status=MagickReadImage(contrast_wand,argv[1]); |
| 342 | if (status == MagickFalse) |
| 343 | ThrowWandException(contrast_wand); |
| 344 | /* |
| 345 | Sigmoidal non-linearity contrast control. |
| 346 | */ |
cristy | 10c8715 | 2010-06-26 16:12:21 +0000 | [diff] [blame] | 347 | contrast_view=NewWandView(contrast_wand); |
| 348 | if (contrast_view == (WandView *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 349 | ThrowWandException(contrast_wand); |
cristy | 10c8715 | 2010-06-26 16:12:21 +0000 | [diff] [blame] | 350 | status=UpdateWandViewIterator(contrast_view,SigmoidalContrast,(void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 351 | if (status == MagickFalse) |
| 352 | ThrowWandException(contrast_wand); |
cristy | 10c8715 | 2010-06-26 16:12:21 +0000 | [diff] [blame] | 353 | contrast_view=DestroyWandView(contrast_view); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 354 | /* |
| 355 | Write the image then destroy it. |
| 356 | */ |
| 357 | status=MagickWriteImages(contrast_wand,argv[2],MagickTrue); |
| 358 | if (status == MagickFalse) |
| 359 | ThrowWandException(contrast_wand); |
| 360 | contrast_wand=DestroyMagickWand(contrast_wand); |
| 361 | MagickWandTerminus(); |
| 362 | return(0); |
| 363 | } |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 364 | </pre> |
Cristy | a3de16b | 2017-05-14 12:25:22 -0400 | [diff] [blame] | 365 | <p><a href="../MagickWand/index.html">MagickWand Examples in C</a> illustrates how to use the ImageMagick MagickWand API. Each example is presented as a C function, complete with headers, so that it can be copied to a file and then included in your own C project.</p> |
cristy | dcca3fa | 2010-12-29 21:50:07 +0000 | [diff] [blame] | 366 | </div> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 367 | <footer class="magick-footer"> |
cristy | 29f2c97 | 2015-07-28 13:37:46 +0000 | [diff] [blame] | 368 | <p><a href="support.html">Donate</a> • |
| 369 | <a href="sitemap.html">Sitemap</a> • |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 370 | <a href="links.html">Related</a> • |
Cristy | e077971 | 2016-07-30 17:25:22 -0400 | [diff] [blame] | 371 | <a href="security-policy.html">Security</a> • |
cristy | 29f2c97 | 2015-07-28 13:37:46 +0000 | [diff] [blame] | 372 | <a href="architecture.html">Architecture</a> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 373 | </p> |
| 374 | <p><a href="magick-wand.html#">Back to top</a> • |
cristy | ea2793e | 2015-05-31 16:52:26 +0000 | [diff] [blame] | 375 | <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> • |
Cristy | 6549abb | 2016-11-10 08:25:55 -0500 | [diff] [blame] | 376 | <a href="https://www.imagemagick.org/script/contact.php">Contact Us</a></p> |
Cristy | fe36f99 | 2016-12-29 20:24:13 -0500 | [diff] [blame] | 377 | <p><small>© 1999-2017 ImageMagick Studio LLC</small></p> |
cristy | d243201 | 2015-05-04 23:15:15 +0000 | [diff] [blame] | 378 | </footer> |
| 379 | </div><!-- /.container --> |
cristy | ad41c0c | 2012-10-31 00:49:28 +0000 | [diff] [blame] | 380 | |
Cristy | b7f455a | 2017-03-03 19:30:34 -0500 | [diff] [blame] | 381 | <script src="https://localhost/ajax/libs/jquery/1.12.4/jquery.min.js"></script> |
Cristy | 1f1f3a0 | 2016-06-01 07:25:42 -0400 | [diff] [blame] | 382 | <script src="../js/magick.html"></script> |
cristy | ad41c0c | 2012-10-31 00:49:28 +0000 | [diff] [blame] | 383 | </div> |
cristy | ad41c0c | 2012-10-31 00:49:28 +0000 | [diff] [blame] | 384 | </body> |
cristy | 5a367e4 | 2015-05-05 12:39:18 +0000 | [diff] [blame] | 385 | </html> |
Cristy | ae7da2d | 2017-05-18 09:41:17 -0400 | [diff] [blame] | 386 | <!-- Magick Cache 17th May 2017 15:37 --> |