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: Image Distortions</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:, image, distortions, 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="distort.html#AffineTransformImage">AffineTransformImage</a> &#8226; <a href="distort.html#DistortImage">DistortImage</a> &#8226; <a href="distort.html#RotateImage">RotateImage</a> &#8226; <a href="distort.html#SparseColorImage">SparseColorImage</a></p>
     60 
     61 <h2><a href="http://www.imagemagick.org/api/MagickCore/distort_8c.html" id="AffineTransformImage">AffineTransformImage</a></h2>
     62 
     63 <p>AffineTransformImage() transforms an image as dictated by the affine matrix. It allocates the memory necessary for the new Image structure and returns a pointer to the new image.</p>
     64 
     65 <p>The format of the AffineTransformImage method is:</p>
     66 
     67 <pre class="text">
     68 Image *AffineTransformImage(const Image *image,
     69   AffineMatrix *affine_matrix,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>affine_matrix</dt>
     84 <dd>the affine matrix. </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/distort_8c.html" id="DistortImage">DistortImage</a></h2>
     93 
     94 <p>DistortImage() distorts an image using various distortion methods, by mapping color lookups of the source image to a new destination image usally of the same size as the source image, unless 'bestfit' is set to true.</p>
     95 
     96 <p>If 'bestfit' is enabled, and distortion allows it, the destination image is adjusted to ensure the whole source 'image' will just fit within the final destination image, which will be sized and offset accordingly.  Also in many cases the virtual offset of the source image will be taken into account in the mapping.</p>
     97 
     98 <p>If the '-verbose' control option has been set print to standard error the equicelent '-fx' formula with coefficients for the function, if practical.</p>
     99 
    100 <p>The format of the DistortImage() method is:</p>
    101 
    102 <pre class="text">
    103 Image *DistortImage(const Image *image,const DistortMethod method,
    104   const size_t number_arguments,const double *arguments,
    105   MagickBooleanType bestfit, ExceptionInfo *exception)
    106 </pre>
    107 
    108 <p>A description of each parameter follows:</p>
    109 
    110 <dd>
    111 </dd>
    112 
    113 <dd> </dd>
    114 <dl class="dl-horizontal">
    115 <dt>image</dt>
    116 <dd>the image to be distorted. </dd>
    117 
    118 <dd> </dd>
    119 <dt>method</dt>
    120 <dd>the method of image distortion. </dd>
    121 
    122 <dd> ArcDistortion always ignores source image offset, and always 'bestfit' the destination image with the top left corner offset relative to the polar mapping center. </dd>
    123 
    124 <dd> Affine, Perspective, and Bilinear, do least squares fitting of the distrotion when more than the minimum number of control point pairs are provided. </dd>
    125 
    126 <dd> Perspective, and Bilinear, fall back to a Affine distortion when less than 4 control point pairs are provided.  While Affine distortions let you use any number of control point pairs, that is Zero pairs is a No-Op (viewport only) distortion, one pair is a translation and two pairs of control points do a scale-rotate-translate, without any shearing. </dd>
    127 
    128 <dd> </dd>
    129 <dt>number_arguments</dt>
    130 <dd>the number of arguments given. </dd>
    131 
    132 <dd> </dd>
    133 <dt>arguments</dt>
    134 <dd>an array of floating point arguments for this method. </dd>
    135 
    136 <dd> </dd>
    137 <dt>bestfit</dt>
    138 <dd>Attempt to 'bestfit' the size of the resulting image. This also forces the resulting image to be a 'layered' virtual canvas image.  Can be overridden using 'distort:viewport' setting. </dd>
    139 
    140 <dd> </dd>
    141 <dt>exception</dt>
    142 <dd>return any errors or warnings in this structure </dd>
    143 
    144 <dd> Extra Controls from Image meta-data (artifacts)... </dd>
    145 
    146 <dd> o "verbose" Output to stderr alternatives, internal coefficents, and FX equivalents for the distortion operation (if feasible). This forms an extra check of the distortion method, and allows users access to the internal constants IM calculates for the distortion. </dd>
    147 
    148 <dd> o "distort:viewport" Directly set the output image canvas area and offest to use for the resulting image, rather than use the original images canvas, or a calculated 'bestfit' canvas. </dd>
    149 
    150 <dd> o "distort:scale" Scale the size of the output canvas by this amount to provide a method of Zooming, and for super-sampling the results. </dd>
    151 
    152 <dd> Other settings that can effect results include </dd>
    153 
    154 <dd> o 'interpolate' For source image lookups (scale enlargements) </dd>
    155 
    156 <dd> o 'filter'      Set filter to use for area-resampling (scale shrinking). Set to 'point' to turn off and use 'interpolate' lookup instead </dd>
    157 
    158 <dd>  </dd>
    159 </dl>
    160 <h2><a href="http://www.imagemagick.org/api/MagickCore/distort_8c.html" id="RotateImage">RotateImage</a></h2>
    161 
    162 <p>RotateImage() creates a new image that is a rotated copy of an existing one.  Positive angles rotate counter-clockwise (right-hand rule), while negative angles rotate clockwise.  Rotated images are usually larger than the originals and have 'empty' triangular corners.  X axis.  Empty triangles left over from shearing the image are filled with the background color defined by member 'background_color' of the image.  RotateImage allocates the memory necessary for the new Image structure and returns a pointer to the new image.</p>
    163 
    164 <p>The format of the RotateImage method is:</p>
    165 
    166 <pre class="text">
    167 Image *RotateImage(const Image *image,const double degrees,
    168   ExceptionInfo *exception)
    169 </pre>
    170 
    171 <p>A description of each parameter follows.</p>
    172 
    173 <dt>image</dt>
    174 <p>the image.</p>
    175 
    176 <dt>degrees</dt>
    177 <p>Specifies the number of degrees to rotate the image.</p>
    178 
    179 <dt>exception</dt>
    180 <p>return any errors or warnings in this structure.</p>
    181 
    182 <h2><a href="http://www.imagemagick.org/api/MagickCore/distort_8c.html" id="SparseColorImage">SparseColorImage</a></h2>
    183 
    184 <p>SparseColorImage(), given a set of coordinates, interpolates the colors found at those coordinates, across the whole image, using various methods.</p>
    185 
    186 <p>The format of the SparseColorImage() method is:</p>
    187 
    188 <pre class="text">
    189 Image *SparseColorImage(const Image *image,
    190   const SparseColorMethod method,const size_t number_arguments,
    191   const double *arguments,ExceptionInfo *exception)
    192 </pre>
    193 
    194 <p>A description of each parameter follows:</p>
    195 
    196 <dd>
    197 </dd>
    198 
    199 <dd> </dd>
    200 <dl class="dl-horizontal">
    201 <dt>image</dt>
    202 <dd>the image to be filled in. </dd>
    203 
    204 <dd> </dd>
    205 <dt>method</dt>
    206 <dd>the method to fill in the gradient between the control points. </dd>
    207 
    208 <dd> The methods used for SparseColor() are often simular to methods used for DistortImage(), and even share the same code for determination of the function coefficents, though with more dimensions (or resulting values). </dd>
    209 
    210 <dd> </dd>
    211 <dt>number_arguments</dt>
    212 <dd>the number of arguments given. </dd>
    213 
    214 <dd> </dd>
    215 <dt>arguments</dt>
    216 <dd>array of floating point arguments for this method-- x,y,color_values-- with color_values given as normalized values. </dd>
    217 
    218 <dd> </dd>
    219 <dt>exception</dt>
    220 <dd>return any errors or warnings in this structure </dd>
    221 
    222 <dd>  </dd>
    223 </dl>
    224 </div>
    225   <footer class="magick-footer">
    226     <p><a href="../support.html">Donate</a> 
    227      <a href="../sitemap.html">Sitemap</a> 
    228     <a href="../links.html">Related</a> 
    229     <a href="../architecture.html">Architecture</a>
    230 </p>
    231     <p><a href="distort.html#">Back to top</a> 
    232     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 
    233     <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
    234         <p><small>  1999-2016 ImageMagick Studio LLC</small></p>
    235   </footer>
    236 </div><!-- /.container -->
    237 
    238   <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    239   <script src="../js/magick.html"></script>
    240 </div>
    241 </body>
    242 </html>
    243