Home | History | Annotate | Download | only in api
      1 
      2 
      3 
      4 
      5 <!DOCTYPE html>
      6 <html lang="en">
      7 <head>
      8     <title>ImageMagick: MagickCore, C API for ImageMagick: Transform an Image</title>
      9   <meta charset="utf-8" />
     10   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
     11   <meta name="viewport" content="width=device-width, initial-scale=1" />
     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 Bzier curves."/>
     15   <meta name="application-url" content="http://www.imagemagick.org"/>
     16   <meta name="generator" content="PHP"/>
     17   <meta name="keywords" content="magickcore, c, api, for, imagemagick:, transform, an, image, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
     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"/>
     24   <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
     25   <meta name="distribution" content="Global"/>
     26   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
     27   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
     28   <link rel="icon" href="../images/wand.png"/>
     29   <link rel="shortcut icon" href="../images/wand.ico"/>
     30   <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">
     31   <link rel="stylesheet" href="../css/magick.html"/>
     32 </head>
     33 <body>
     34 <div class="main">
     35 <div class="magick-masthead">
     36   <div class="container">
     37     <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
     38          style="display:block"
     39          data-ad-client="ca-pub-3129977114552745"
     40          data-ad-slot="6345125851"
     41          data-ad-format="auto"></ins>
     42     <script>
     43       (adsbygoogle = window.adsbygoogle || []).push({});
     44     </script>
     45     <nav class="magick-nav">
     46       <a class="magick-nav-item " href="../index.html">Home</a>
     47       <a class="magick-nav-item " href="../binary-releases.html">Download</a>
     48       <a class="magick-nav-item " href="../command-line-tools.html">Tools</a>
     49       <a class="magick-nav-item " href="../command-line-processing.html">Command-line</a>
     50       <a class="magick-nav-item " href="../resources.html">Resources</a>
     51       <a class="magick-nav-item " href="api.html">Develop</a>
     52       <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
     53       <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
     54     </nav>
     55   </div>
     56 </div>
     57 <div class="container">
     58 <div class="magick-header">
     59 <p class="text-center"><a href="transform.html#AutoOrientImage">AutoOrientImage</a> &#8226; <a href="transform.html#ChopImage">ChopImage</a> &#8226; <a href="transform.html#CropImage">CropImage</a> &#8226; <a href="transform.html#CropImageToTiles">CropImageToTiles</a> &#8226; <a href="transform.html#ExcerptImage">ExcerptImage</a> &#8226; <a href="transform.html#ExtentImage">ExtentImage</a> &#8226; <a href="transform.html#FlipImage">FlipImage</a> &#8226; <a href="transform.html#FlopImage">FlopImage</a> &#8226; <a href="transform.html#RollImage">RollImage</a> &#8226; <a href="transform.html#ShaveImage">ShaveImage</a> &#8226; <a href="transform.html#SpliceImage">SpliceImage</a> &#8226; <a href="transform.html#TransformImage">TransformImage</a> &#8226; <a href="transform.html#TransposeImage">TransposeImage</a> &#8226; <a href="transform.html#TransverseImage">TransverseImage</a> &#8226; <a href="transform.html#TrimImage">TrimImage</a></p>
     60 
     61 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="AutoOrientImage">AutoOrientImage</a></h2>
     62 
     63 <p>AutoOrientImage() adjusts an image so that its orientation is suitable for viewing (i.e. top-left orientation).</p>
     64 
     65 <p>The format of the AutoOrientImage method is:</p>
     66 
     67 <pre class="text">
     68 Image *AutoOrientImage(const Image *image,
     69   const OrientationType orientation,ExceptionInfo *exception)
     70 </pre>
     71 
     72 <p>A description of each parameter follows:</p>
     73 
     74 <dd>
     75 </dd>
     76 
     77 <dd> </dd>
     78 <dl class="dl-horizontal">
     79 <dt>image</dt>
     80 <dd>The image. </dd>
     81 
     82 <dd> </dd>
     83 <dt>orientation</dt>
     84 <dd>Current image orientation. </dd>
     85 
     86 <dd> </dd>
     87 <dt>exception</dt>
     88 <dd>Return any errors or warnings in this structure. </dd>
     89 
     90 <dd>  </dd>
     91 </dl>
     92 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="ChopImage">ChopImage</a></h2>
     93 
     94 <p>ChopImage() removes a region of an image and collapses the image to occupy the removed portion.</p>
     95 
     96 <p>The format of the ChopImage method is:</p>
     97 
     98 <pre class="text">
     99 Image *ChopImage(const Image *image,const RectangleInfo *chop_info)
    100   ExceptionInfo *exception)
    101 </pre>
    102 
    103 <p>A description of each parameter follows:</p>
    104 
    105 <dd>
    106 </dd>
    107 
    108 <dd> </dd>
    109 <dl class="dl-horizontal">
    110 <dt>image</dt>
    111 <dd>the image. </dd>
    112 
    113 <dd> </dd>
    114 <dt>chop_info</dt>
    115 <dd>Define the region of the image to chop. </dd>
    116 
    117 <dd> </dd>
    118 <dt>exception</dt>
    119 <dd>return any errors or warnings in this structure. </dd>
    120 
    121 <dd>  </dd>
    122 </dl>
    123 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="CropImage">CropImage</a></h2>
    124 
    125 <p>CropImage() extracts a region of the image starting at the offset defined by geometry.  Region must be fully defined, and no special handling of geometry flags is performed.</p>
    126 
    127 <p>The format of the CropImage method is:</p>
    128 
    129 <pre class="text">
    130 Image *CropImage(const Image *image,const RectangleInfo *geometry,
    131   ExceptionInfo *exception)
    132 </pre>
    133 
    134 <p>A description of each parameter follows:</p>
    135 
    136 <dd>
    137 </dd>
    138 
    139 <dd> </dd>
    140 <dl class="dl-horizontal">
    141 <dt>image</dt>
    142 <dd>the image. </dd>
    143 
    144 <dd> </dd>
    145 <dt>geometry</dt>
    146 <dd>Define the region of the image to crop with members x, y, width, and height. </dd>
    147 
    148 <dd> </dd>
    149 <dt>exception</dt>
    150 <dd>return any errors or warnings in this structure. </dd>
    151 
    152 <dd>  </dd>
    153 </dl>
    154 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="CropImageToTiles">CropImageToTiles</a></h2>
    155 
    156 <p>CropImageToTiles() crops a single image, into a possible list of tiles. This may include a single sub-region of the image.  This basically applies all the normal geometry flags for Crop.</p>
    157 
    158 <p>Image *CropImageToTiles(const Image *image, const RectangleInfo *crop_geometry, ExceptionInfo *exception)</p>
    159 
    160 <p>A description of each parameter follows:</p>
    161 
    162 <dd>
    163 </dd>
    164 
    165 <dd> </dd>
    166 <dl class="dl-horizontal">
    167 <dt>image</dt>
    168 <dd>the image The transformed image is returned as this parameter. </dd>
    169 
    170 <dd> </dd>
    171 <dt>crop_geometry</dt>
    172 <dd>A crop geometry string. </dd>
    173 
    174 <dd> </dd>
    175 <dt>exception</dt>
    176 <dd>return any errors or warnings in this structure. </dd>
    177 
    178 <dd>  </dd>
    179 </dl>
    180 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="ExcerptImage">ExcerptImage</a></h2>
    181 
    182 <p>ExcerptImage() returns a excerpt of the image as defined by the geometry.</p>
    183 
    184 <p>The format of the ExcerptImage method is:</p>
    185 
    186 <pre class="text">
    187 Image *ExcerptImage(const Image *image,const RectangleInfo *geometry,
    188   ExceptionInfo *exception)
    189 </pre>
    190 
    191 <p>A description of each parameter follows:</p>
    192 
    193 <dd>
    194 </dd>
    195 
    196 <dd> </dd>
    197 <dl class="dl-horizontal">
    198 <dt>image</dt>
    199 <dd>the image. </dd>
    200 
    201 <dd> </dd>
    202 <dt>geometry</dt>
    203 <dd>Define the region of the image to extend with members x, y, width, and height. </dd>
    204 
    205 <dd> </dd>
    206 <dt>exception</dt>
    207 <dd>return any errors or warnings in this structure. </dd>
    208 
    209 <dd>  </dd>
    210 </dl>
    211 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="ExtentImage">ExtentImage</a></h2>
    212 
    213 <p>ExtentImage() extends the image as defined by the geometry, gravity, and image background color.  Set the (x,y) offset of the geometry to move the original image relative to the extended image.</p>
    214 
    215 <p>The format of the ExtentImage method is:</p>
    216 
    217 <pre class="text">
    218 Image *ExtentImage(const Image *image,const RectangleInfo *geometry,
    219   ExceptionInfo *exception)
    220 </pre>
    221 
    222 <p>A description of each parameter follows:</p>
    223 
    224 <dd>
    225 </dd>
    226 
    227 <dd> </dd>
    228 <dl class="dl-horizontal">
    229 <dt>image</dt>
    230 <dd>the image. </dd>
    231 
    232 <dd> </dd>
    233 <dt>geometry</dt>
    234 <dd>Define the region of the image to extend with members x, y, width, and height. </dd>
    235 
    236 <dd> </dd>
    237 <dt>exception</dt>
    238 <dd>return any errors or warnings in this structure. </dd>
    239 
    240 <dd>  </dd>
    241 </dl>
    242 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="FlipImage">FlipImage</a></h2>
    243 
    244 <p>FlipImage() creates a vertical mirror image by reflecting the pixels around the central x-axis.</p>
    245 
    246 <p>The format of the FlipImage method is:</p>
    247 
    248 <pre class="text">
    249 Image *FlipImage(const Image *image,ExceptionInfo *exception)
    250 </pre>
    251 
    252 <p>A description of each parameter follows:</p>
    253 
    254 <dd>
    255 </dd>
    256 
    257 <dd> </dd>
    258 <dl class="dl-horizontal">
    259 <dt>image</dt>
    260 <dd>the image. </dd>
    261 
    262 <dd> </dd>
    263 <dt>exception</dt>
    264 <dd>return any errors or warnings in this structure. </dd>
    265 
    266 <dd>  </dd>
    267 </dl>
    268 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="FlopImage">FlopImage</a></h2>
    269 
    270 <p>FlopImage() creates a horizontal mirror image by reflecting the pixels around the central y-axis.</p>
    271 
    272 <p>The format of the FlopImage method is:</p>
    273 
    274 <pre class="text">
    275 Image *FlopImage(const Image *image,ExceptionInfo *exception)
    276 </pre>
    277 
    278 <p>A description of each parameter follows:</p>
    279 
    280 <dd>
    281 </dd>
    282 
    283 <dd> </dd>
    284 <dl class="dl-horizontal">
    285 <dt>image</dt>
    286 <dd>the image. </dd>
    287 
    288 <dd> </dd>
    289 <dt>exception</dt>
    290 <dd>return any errors or warnings in this structure. </dd>
    291 
    292 <dd>  </dd>
    293 </dl>
    294 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="RollImage">RollImage</a></h2>
    295 
    296 <p>RollImage() offsets an image as defined by x_offset and y_offset.</p>
    297 
    298 <p>The format of the RollImage method is:</p>
    299 
    300 <pre class="text">
    301 Image *RollImage(const Image *image,const ssize_t x_offset,
    302   const ssize_t y_offset,ExceptionInfo *exception)
    303 </pre>
    304 
    305 <p>A description of each parameter follows:</p>
    306 
    307 <dd>
    308 </dd>
    309 
    310 <dd> </dd>
    311 <dl class="dl-horizontal">
    312 <dt>image</dt>
    313 <dd>the image. </dd>
    314 
    315 <dd> </dd>
    316 <dt>x_offset</dt>
    317 <dd>the number of columns to roll in the horizontal direction. </dd>
    318 
    319 <dd> </dd>
    320 <dt>y_offset</dt>
    321 <dd>the number of rows to roll in the vertical direction. </dd>
    322 
    323 <dd> </dd>
    324 <dt>exception</dt>
    325 <dd>return any errors or warnings in this structure. </dd>
    326 
    327 <dd>  </dd>
    328 </dl>
    329 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="ShaveImage">ShaveImage</a></h2>
    330 
    331 <p>ShaveImage() shaves pixels from the image edges.  It allocates the memory necessary for the new Image structure and returns a pointer to the new image.</p>
    332 
    333 <p>The format of the ShaveImage method is:</p>
    334 
    335 <pre class="text">
    336 Image *ShaveImage(const Image *image,const RectangleInfo *shave_info,
    337   ExceptionInfo *exception)
    338 </pre>
    339 
    340 <p>A description of each parameter follows:</p>
    341 
    342 <dd>
    343 </dd>
    344 
    345 <dd> </dd>
    346 <dl class="dl-horizontal">
    347 <dt>shave_image</dt>
    348 <dd>Method ShaveImage returns a pointer to the shaved image.  A null image is returned if there is a memory shortage or if the image width or height is zero. </dd>
    349 
    350 <dd> </dd>
    351 <dt>image</dt>
    352 <dd>the image. </dd>
    353 
    354 <dd> </dd>
    355 <dt>shave_info</dt>
    356 <dd>Specifies a pointer to a RectangleInfo which defines the region of the image to crop. </dd>
    357 
    358 <dd> </dd>
    359 <dt>exception</dt>
    360 <dd>return any errors or warnings in this structure. </dd>
    361 
    362 <dd>  </dd>
    363 </dl>
    364 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="SpliceImage">SpliceImage</a></h2>
    365 
    366 <p>SpliceImage() splices a solid color into the image as defined by the geometry.</p>
    367 
    368 <p>The format of the SpliceImage method is:</p>
    369 
    370 <pre class="text">
    371 Image *SpliceImage(const Image *image,const RectangleInfo *geometry,
    372   ExceptionInfo *exception)
    373 </pre>
    374 
    375 <p>A description of each parameter follows:</p>
    376 
    377 <dd>
    378 </dd>
    379 
    380 <dd> </dd>
    381 <dl class="dl-horizontal">
    382 <dt>image</dt>
    383 <dd>the image. </dd>
    384 
    385 <dd> </dd>
    386 <dt>geometry</dt>
    387 <dd>Define the region of the image to splice with members x, y, width, and height. </dd>
    388 
    389 <dd> </dd>
    390 <dt>exception</dt>
    391 <dd>return any errors or warnings in this structure. </dd>
    392 
    393 <dd>  </dd>
    394 </dl>
    395 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="TransformImage">TransformImage</a></h2>
    396 
    397 <p>TransformImage() is a convenience method that behaves like ResizeImage() or CropImage() but accepts scaling and/or cropping information as a region geometry specification.  If the operation fails, the original image handle is left as is.</p>
    398 
    399 <p>This should only be used for single images.</p>
    400 
    401 <p>This function destroys what it assumes to be a single image list. If the input image is part of a larger list, all other images in that list will be simply 'lost', not destroyed.</p>
    402 
    403 <p>Also if the crop generates a list of images only the first image is resized. And finally if the crop succeeds and the resize failed, you will get a cropped image, as well as a 'false' or 'failed' report.</p>
    404 
    405 <p>This function and should probably be deprecated in favor of direct calls to CropImageToTiles() or ResizeImage(), as appropriate.</p>
    406 
    407 <p>The format of the TransformImage method is:</p>
    408 
    409 <pre class="text">
    410 MagickBooleanType TransformImage(Image **image,const char *crop_geometry,
    411   const char *image_geometry,ExceptionInfo *exception)
    412 </pre>
    413 
    414 <p>A description of each parameter follows:</p>
    415 
    416 <dd>
    417 </dd>
    418 
    419 <dd> </dd>
    420 <dl class="dl-horizontal">
    421 <dt>image</dt>
    422 <dd>the image The transformed image is returned as this parameter. </dd>
    423 
    424 <dd> </dd>
    425 <dt>crop_geometry</dt>
    426 <dd>A crop geometry string.  This geometry defines a subregion of the image to crop. </dd>
    427 
    428 <dd> </dd>
    429 <dt>image_geometry</dt>
    430 <dd>An image geometry string.  This geometry defines the final size of the image. </dd>
    431 
    432 <dd> </dd>
    433 <dt>exception</dt>
    434 <dd>return any errors or warnings in this structure. </dd>
    435 
    436 <dd>  </dd>
    437 </dl>
    438 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="TransposeImage">TransposeImage</a></h2>
    439 
    440 <p>TransposeImage() creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them by 90 degrees.</p>
    441 
    442 <p>The format of the TransposeImage method is:</p>
    443 
    444 <pre class="text">
    445 Image *TransposeImage(const Image *image,ExceptionInfo *exception)
    446 </pre>
    447 
    448 <p>A description of each parameter follows:</p>
    449 
    450 <dd>
    451 </dd>
    452 
    453 <dd> </dd>
    454 <dl class="dl-horizontal">
    455 <dt>image</dt>
    456 <dd>the image. </dd>
    457 
    458 <dd> </dd>
    459 <dt>exception</dt>
    460 <dd>return any errors or warnings in this structure. </dd>
    461 
    462 <dd>  </dd>
    463 </dl>
    464 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="TransverseImage">TransverseImage</a></h2>
    465 
    466 <p>TransverseImage() creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them by 270 degrees.</p>
    467 
    468 <p>The format of the TransverseImage method is:</p>
    469 
    470 <pre class="text">
    471 Image *TransverseImage(const Image *image,ExceptionInfo *exception)
    472 </pre>
    473 
    474 <p>A description of each parameter follows:</p>
    475 
    476 <dd>
    477 </dd>
    478 
    479 <dd> </dd>
    480 <dl class="dl-horizontal">
    481 <dt>image</dt>
    482 <dd>the image. </dd>
    483 
    484 <dd> </dd>
    485 <dt>exception</dt>
    486 <dd>return any errors or warnings in this structure. </dd>
    487 
    488 <dd>  </dd>
    489 </dl>
    490 <h2><a href="http://www.imagemagick.org/api/MagickCore/transform_8c.html" id="TrimImage">TrimImage</a></h2>
    491 
    492 <p>TrimImage() trims pixels from the image edges.  It allocates the memory necessary for the new Image structure and returns a pointer to the new image.</p>
    493 
    494 <p>The format of the TrimImage method is:</p>
    495 
    496 <pre class="text">
    497 Image *TrimImage(const Image *image,ExceptionInfo *exception)
    498 </pre>
    499 
    500 <p>A description of each parameter follows:</p>
    501 
    502 <dd>
    503 </dd>
    504 
    505 <dd> </dd>
    506 <dl class="dl-horizontal">
    507 <dt>image</dt>
    508 <dd>the image. </dd>
    509 
    510 <dd> </dd>
    511 <dt>exception</dt>
    512 <dd>return any errors or warnings in this structure. </dd>
    513 
    514 <dd>  </dd>
    515 </dl>
    516 </div>
    517   <footer class="magick-footer">
    518     <p><a href="../support.html">Donate</a> 
    519      <a href="../sitemap.html">Sitemap</a> 
    520     <a href="../links.html">Related</a> 
    521     <a href="../architecture.html">Architecture</a>
    522 </p>
    523     <p><a href="transform.html#">Back to top</a> 
    524     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 
    525     <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
    526         <p><small>  1999-2016 ImageMagick Studio LLC</small></p>
    527   </footer>
    528 </div><!-- /.container -->
    529 
    530   <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    531   <script src="../js/magick.html"></script>
    532 </div>
    533 </body>
    534 </html>
    535