Home | History | Annotate | Download | only in api
      1 
      2 
      3 
      4 
      5 <!DOCTYPE html>
      6 <html lang="en">
      7 <head>
      8   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
      9     <title>ImageMagick: MagickCore, C API for ImageMagick: Image Distortions</title>
     10   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
     11   <meta name="application-name" content="ImageMagick"/>
     12   <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."/>
     13   <meta name="application-url" content="http://www.imagemagick.org"/>
     14   <meta name="generator" content="PHP"/>
     15   <meta name="keywords" content="magickcore, c, api, for, imagemagick:, image, distortions, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
     16   <meta name="rating" content="GENERAL"/>
     17   <meta name="robots" content="INDEX, FOLLOW"/>
     18   <meta name="generator" content="ImageMagick Studio LLC"/>
     19   <meta name="author" content="ImageMagick Studio LLC"/>
     20   <meta name="revisit-after" content="2 DAYS"/>
     21   <meta name="resource-type" content="document"/>
     22   <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
     23   <meta name="distribution" content="Global"/>
     24   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
     25   <link rel="icon" href="../image/wand.png"/>
     26   <link rel="shortcut icon" href="../image/wand.ico"/>
     27   <link rel="stylesheet" href="../css/magick.php"/>
     28 </head>
     29 <body>
     30 <div class="main">
     31 <div class="magick-masthead">
     32   <div class="container">
     33     <script async="async" src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
     34          style="display:block"
     35          data-ad-client="ca-pub-3129977114552745"
     36          data-ad-slot="6345125851"
     37          data-ad-format="auto"></ins>
     38     <script>
     39       (adsbygoogle = window.adsbygoogle || []).push({});
     40     </script>
     41     <nav class="magick-nav">
     42       <a class="magick-nav-item " href="../index.php">Home</a>
     43       <a class="magick-nav-item " href="../script/binary-releases.php">Download</a>
     44       <a class="magick-nav-item " href="../script/command-line-tools.php">Tools</a>
     45       <a class="magick-nav-item " href="../script/command-line-options.php">Options</a>
     46       <a class="magick-nav-item " href="../script/resources.php">Resources</a>
     47       <a class="magick-nav-item " href="../script/api.php">Develop</a>
     48       <a class="magick-nav-item " href="../script/search.php">Search</a>
     49       <a class="magick-nav-item pull-right" href="http://www.imagemagick.org/discourse-server/">Community</a>
     50     </nav>
     51   </div>
     52 </div>
     53 <div class="container">
     54 <div class="magick-header">
     55 <p class="text-center"><a href="distort.php#AffineTransformImage">AffineTransformImage</a> &bull; <a href="distort.php#DistortImage">DistortImage</a> &bull; <a href="distort.php#RotateImage">RotateImage</a> &bull; <a href="distort.php#SparseColorImage">SparseColorImage</a></p>
     56 
     57 <h2><a href="http://nextgen.imagemagick.org/api/MagickCore/distort_8c.html" id="AffineTransformImage">AffineTransformImage</a></h2>
     58 
     59 <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>
     60 
     61 <p>The format of the AffineTransformImage method is:</p>
     62 
     63 <pre class="text">
     64 Image *AffineTransformImage(const Image *image,
     65   AffineMatrix *affine_matrix,ExceptionInfo *exception)
     66 </pre>
     67 
     68 <p>A description of each parameter follows:</p>
     69 
     70 <dd>
     71 </dd>
     72 
     73 <dd> </dd>
     74 <dl class="dl-horizontal">
     75 <dt>image</dt>
     76 <dd>the image. </dd>
     77 
     78 <dd> </dd>
     79 <dt>affine_matrix</dt>
     80 <dd>the affine matrix. </dd>
     81 
     82 <dd> </dd>
     83 <dt>exception</dt>
     84 <dd>return any errors or warnings in this structure. </dd>
     85 
     86 <dd>  </dd>
     87 </dl>
     88 <h2><a href="http://nextgen.imagemagick.org/api/MagickCore/distort_8c.html" id="DistortImage">DistortImage</a></h2>
     89 
     90 <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>
     91 
     92 <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>
     93 
     94 <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>
     95 
     96 <p>The format of the DistortImage() method is:</p>
     97 
     98 <pre class="text">
     99 Image *DistortImage(const Image *image,const DistortImageMethod method,
    100   const size_t number_arguments,const double *arguments,
    101   MagickBooleanType bestfit, ExceptionInfo *exception)
    102 </pre>
    103 
    104 <p>A description of each parameter follows:</p>
    105 
    106 <dd>
    107 </dd>
    108 
    109 <dd> </dd>
    110 <dl class="dl-horizontal">
    111 <dt>image</dt>
    112 <dd>the image to be distorted. </dd>
    113 
    114 <dd> </dd>
    115 <dt>method</dt>
    116 <dd>the method of image distortion. </dd>
    117 
    118 <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>
    119 
    120 <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>
    121 
    122 <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>
    123 
    124 <dd> </dd>
    125 <dt>number_arguments</dt>
    126 <dd>the number of arguments given. </dd>
    127 
    128 <dd> </dd>
    129 <dt>arguments</dt>
    130 <dd>an array of floating point arguments for this method. </dd>
    131 
    132 <dd> </dd>
    133 <dt>bestfit</dt>
    134 <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>
    135 
    136 <dd> </dd>
    137 <dt>exception</dt>
    138 <dd>return any errors or warnings in this structure </dd>
    139 
    140 <dd> Extra Controls from Image meta-data (artifacts)... </dd>
    141 
    142 <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>
    143 
    144 <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>
    145 
    146 <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>
    147 
    148 <dd> Other settings that can effect results include </dd>
    149 
    150 <dd> o 'interpolate' For source image lookups (scale enlargements) </dd>
    151 
    152 <dd> o 'filter'      Set filter to use for area-resampling (scale shrinking). Set to 'point' to turn off and use 'interpolate' lookup instead </dd>
    153 
    154 <dd>  </dd>
    155 </dl>
    156 <h2><a href="http://nextgen.imagemagick.org/api/MagickCore/distort_8c.html" id="RotateImage">RotateImage</a></h2>
    157 
    158 <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>
    159 
    160 <p>The format of the RotateImage method is:</p>
    161 
    162 <pre class="text">
    163 Image *RotateImage(const Image *image,const double degrees,
    164   ExceptionInfo *exception)
    165 </pre>
    166 
    167 <p>A description of each parameter follows.</p>
    168 
    169 <dt>image</dt>
    170 <p>the image.</p>
    171 
    172 <dt>degrees</dt>
    173 <p>Specifies the number of degrees to rotate the image.</p>
    174 
    175 <dt>exception</dt>
    176 <p>return any errors or warnings in this structure.</p>
    177 
    178 <h2><a href="http://nextgen.imagemagick.org/api/MagickCore/distort_8c.html" id="SparseColorImage">SparseColorImage</a></h2>
    179 
    180 <p>SparseColorImage(), given a set of coordinates, interpolates the colors found at those coordinates, across the whole image, using various methods.</p>
    181 
    182 <p>The format of the SparseColorImage() method is:</p>
    183 
    184 <pre class="text">
    185 Image *SparseColorImage(const Image *image,
    186   const SparseColorMethod method,const size_t number_arguments,
    187   const double *arguments,ExceptionInfo *exception)
    188 </pre>
    189 
    190 <p>A description of each parameter follows:</p>
    191 
    192 <dd>
    193 </dd>
    194 
    195 <dd> </dd>
    196 <dl class="dl-horizontal">
    197 <dt>image</dt>
    198 <dd>the image to be filled in. </dd>
    199 
    200 <dd> </dd>
    201 <dt>method</dt>
    202 <dd>the method to fill in the gradient between the control points. </dd>
    203 
    204 <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>
    205 
    206 <dd> </dd>
    207 <dt>number_arguments</dt>
    208 <dd>the number of arguments given. </dd>
    209 
    210 <dd> </dd>
    211 <dt>arguments</dt>
    212 <dd>array of floating point arguments for this method-- x,y,color_values-- with color_values given as normalized values. </dd>
    213 
    214 <dd> </dd>
    215 <dt>exception</dt>
    216 <dd>return any errors or warnings in this structure </dd>
    217 
    218 <dd>  </dd>
    219 </dl>
    220 </div>
    221   <footer class="magick-footer">
    222     <p><a href="../script/support.php">Donate</a> 
    223      <a href="../script/sitemap.php">Sitemap</a> 
    224     <a href="../script/links.php">Related</a> 
    225     <a href="../script/architecture.php">Architecture</a>
    226 </p>
    227     <p><a href="distort.php#">Back to top</a> 
    228     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 
    229     <a href="../script/contact.php">Contact Us</a></p>
    230         <p><small>  1999-2016 ImageMagick Studio LLC</small></p>
    231   </footer>
    232 </div><!-- /.container -->
    233 
    234   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    235   <script src="http://nextgen.imagemagick.org/js/magick.php"></script>
    236 </div>
    237 </body>
    238 </html>
    239