• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3
4
5<!DOCTYPE html>
6<html lang="en">
7<head>
8  <meta charset="utf-8"  />
9  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no"  />
10  <title>ImageMagick - MagickCore, C API: Image Distortions</title>
11  <meta name="application-name" content="ImageMagick" />
12  <meta name="description" content="Use ImageMagick® to create, edit, compose, and convert bitmap images. Resize an image, crop it, change its shades and colors, add captions, and more." />
13  <meta name="application-url" content="https://imagemagick.org" />
14  <meta name="generator" content="PHP" />
15  <meta name="keywords" content="magickcore, c, api:, 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-2020 ImageMagick Studio LLC" />
23  <meta name="distribution" content="Global" />
24  <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1" />
25  <meta property='og:url' content='../../' />
26  <meta property='og:title' content='ImageMagick' />
27  <meta property='og:image' content='../../images/logo.png' />
28  <meta property='og:type' content='website' />
29  <meta property='og:site_name' content='ImageMagick' />
30  <meta property='og:description' content="Convert, Edit, or Compose Bitmap Images" />
31  <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
32  <link href="../www/api/distort.html" rel="canonical" />
33  <link href="../../www/images/wand.png" rel="icon" />
34  <link href="../../www/images/wand.ico" rel="shortcut icon" />
35  <link href="../../www/assets/magick.css" rel="stylesheet" />
36</head>
37<body>
38  <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
39    <a class="navbar-brand" href="../../"><img class="d-block" id="icon" alt="ImageMagick" width="32" height="32" src="../../www/images/wand.ico"/></a>
40    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsMagick" aria-controls="navbarsMagick" aria-expanded="false" aria-label="Toggle navigation">
41      <span class="navbar-toggler-icon"></span>
42    </button>
43
44    <div class="navbar-collapse collapse" id="navbarsMagick" style="">
45    <ul class="navbar-nav mr-auto">
46      <li class="nav-item ">
47        <a class="nav-link" href="../../www/">Home <span class="sr-only">(current)</span></a>
48      </li>
49      <li class="nav-item ">
50        <a class="nav-link" href="../../www/www/download.html">Download</a>
51      </li>
52      <li class="nav-item ">
53        <a class="nav-link" href="../../www/www/command-line-tools.html">Tools</a>
54      </li>
55      <li class="nav-item ">
56        <a class="nav-link" href="../../www/www/command-line-processing.html">Command-line</a>
57      </li>
58      <li class="nav-item ">
59        <a class="nav-link" href="../../www/www/resources.html">Resources</a>
60      </li>
61      <li class="nav-item ">
62        <a class="nav-link" href="../../www/www/develop.html">Develop</a>
63      </li>
64      <li class="nav-item">
65        <a class="nav-link" target="_blank" href="https://imagemagick.org/discourse-server/">Community</a>
66      </li>
67    </ul>
68    <form class="form-inline my-2 my-lg-0" action="../../www/www/search.html">
69      <input class="form-control mr-sm-2" type="text" name="q" placeholder="Search" aria-label="Search">
70      <button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="sa">Search</button>
71    </form>
72    </div>
73  </nav>
74  <div class="container">
75   <script async="async" src="https://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
76         style="display:block"
77         data-ad-client="ca-pub-3129977114552745"
78         data-ad-slot="6345125851"
79         data-full-width-responsive="true"
80         data-ad-format="horizontal"></ins>
81    <script>
82      (adsbygoogle = window.adsbygoogle || []).push({});
83    </script>
84
85  </div>
86
87  <main class="container">
88    <div class="magick-template">
89<div class="magick-header">
90<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>
91
92<h2><a href="../../api/MagickCore/distort_8c.html" id="AffineTransformImage">AffineTransformImage</a></h2>
93
94<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>
95
96<p>The format of the AffineTransformImage method is:</p>
97
98<pre class="text">
99Image *AffineTransformImage(const Image *image,
100  AffineMatrix *affine_matrix,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>affine_matrix</dt>
115<dd>the affine matrix. </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="../../api/MagickCore/distort_8c.html" id="DistortImage">DistortImage</a></h2>
124
125<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>
126
127<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>
128
129<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>
130
131<p>The format of the DistortImage() method is:</p>
132
133<pre class="text">
134Image *DistortImage(const Image *image,const DistortMethod method,
135  const size_t number_arguments,const double *arguments,
136  MagickBooleanType bestfit, ExceptionInfo *exception)
137</pre>
138
139<p>A description of each parameter follows:</p>
140
141<dd>
142</dd>
143
144<dd> </dd>
145<dl class="dl-horizontal">
146<dt>image</dt>
147<dd>the image to be distorted. </dd>
148
149<dd> </dd>
150<dt>method</dt>
151<dd>the method of image distortion. </dd>
152
153<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>
154
155<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>
156
157<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>
158
159<dd> </dd>
160<dt>number_arguments</dt>
161<dd>the number of arguments given. </dd>
162
163<dd> </dd>
164<dt>arguments</dt>
165<dd>an array of floating point arguments for this method. </dd>
166
167<dd> </dd>
168<dt>bestfit</dt>
169<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>
170
171<dd> </dd>
172<dt>exception</dt>
173<dd>return any errors or warnings in this structure </dd>
174
175<dd> Extra Controls from Image meta-data (artifacts)... </dd>
176
177<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>
178
179<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>
180
181<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>
182
183<dd> Other settings that can effect results include </dd>
184
185<dd> o 'interpolate' For source image lookups (scale enlargements) </dd>
186
187<dd> o 'filter'      Set filter to use for area-resampling (scale shrinking). Set to 'point' to turn off and use 'interpolate' lookup instead </dd>
188
189<dd>  </dd>
190</dl>
191<h2><a href="../../api/MagickCore/distort_8c.html" id="RotateImage">RotateImage</a></h2>
192
193<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>
194
195<p>The format of the RotateImage method is:</p>
196
197<pre class="text">
198Image *RotateImage(const Image *image,const double degrees,
199  ExceptionInfo *exception)
200</pre>
201
202<p>A description of each parameter follows.</p>
203
204<dt>image</dt>
205<p>the image.</p>
206
207<dt>degrees</dt>
208<p>Specifies the number of degrees to rotate the image.</p>
209
210<dt>exception</dt>
211<p>return any errors or warnings in this structure.</p>
212
213<h2><a href="../../api/MagickCore/distort_8c.html" id="SparseColorImage">SparseColorImage</a></h2>
214
215<p>SparseColorImage(), given a set of coordinates, interpolates the colors found at those coordinates, across the whole image, using various methods.</p>
216
217<p>The format of the SparseColorImage() method is:</p>
218
219<pre class="text">
220Image *SparseColorImage(const Image *image,
221  const SparseColorMethod method,const size_t number_arguments,
222  const double *arguments,ExceptionInfo *exception)
223</pre>
224
225<p>A description of each parameter follows:</p>
226
227<dd>
228</dd>
229
230<dd> </dd>
231<dl class="dl-horizontal">
232<dt>image</dt>
233<dd>the image to be filled in. </dd>
234
235<dd> </dd>
236<dt>method</dt>
237<dd>the method to fill in the gradient between the control points. </dd>
238
239<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>
240
241<dd> </dd>
242<dt>number_arguments</dt>
243<dd>the number of arguments given. </dd>
244
245<dd> </dd>
246<dt>arguments</dt>
247<dd>array of floating point arguments for this method-- x,y,color_values-- with color_values given as normalized values. </dd>
248
249<dd> </dd>
250<dt>exception</dt>
251<dd>return any errors or warnings in this structure </dd>
252
253<dd>  </dd>
254</dl>
255</div>
256    </div>
257  </main><!-- /.container -->
258  <footer class="magick-footer">
259    <p><a href="../../www/www/security-policy.html">Security</a> •
260    <a href="../../www/www/architecture.html">Architecture</a>
261
262    <a href="distort.html#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../../www/images/wand.ico"/></a>
263
264    <a href="../../www/www/links.html">Related</a> •
265     <a href="../../www/www/sitemap.html">Sitemap</a>
266    <br/>
267    <a href="../../www/www/support.html">Donate</a> •
268    <a href="http://pgp.mit.edu/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
269    <a href="../../www/www/contact.html">Contact Us</a>
270    <br/>
271    <small>© 1999-2020 ImageMagick Studio LLC</small></p>
272  </footer>
273
274  <!-- Javascript assets -->
275  <script src="../../www/assets/magick.js" crossorigin="anonymous"></script>
276  <script>window.jQuery || document.write('<script src="https://localhost/ajax/libs/jquery/3.4.1/jquery.min.js"><\/script>')</script>
277</body>
278</html>
279<!-- Magick Cache 1st January 2020 09:56 -->