ImageMagick - MagickCore, C API: Shear or Rotate an Image by an Arbitrary Angle
Author: ImageMagick Studio LLC
Description: Use ImageMagick® to create, edit, compose, and convert bitmap images. Resize an image, crop it, change its shades and colors, add captions, and more.
Keywords: magickcore, c, api:, shear, or, rotate, an, image, by, an, arbitrary, angle, image converter, image resizer, image editor, photo editor, jpg converter, png converter, tiff converter, vector images, online, free, swiss army

The XShearImage • DeskewImage • IntegralRotateImage • ShearImage • ShearRotateImage

## The XShearImage

The XShearImage() and YShearImage() methods are based on the paper "A Fast Algorithm for General Raster Rotation" by Alan W. Paeth, Graphics Interface '86 (Vancouver). ShearRotateImage() is adapted from a similar method based on the Paeth paper written by Michael Halle of the Spatial Imaging Group, MIT Media Lab.

## DeskewImage

DeskewImage() removes skew from the image. Skew is an artifact that occurs in scanned images because of the camera being misaligned, imperfections in the scanning or surface, or simply because the paper was not placed completely flat when scanned.

The amount of rotation calculated to deskew the image is saved in the artifact "deskew:angle".

If the artifact "deskew:auto-crop" is given the image will be automatically cropped of the excess background.

The format of the DeskewImage method is:

    Image *DeskewImage(const Image *image,const double threshold,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
threshold
  separate background from foreground.
exception
  return any errors or warnings in this structure.

## IntegralRotateImage

IntegralRotateImage() rotates the image an integral of 90 degrees. It allocates the memory necessary for the new Image structure and returns a pointer to the rotated image.

The format of the IntegralRotateImage method is:

    Image *IntegralRotateImage(const Image *image,size_t rotations,
      ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

rotations

Specifies the number of 90 degree rotations.

## ShearImage

ShearImage() creates a new image that is a shear_image copy of an existing one. Shearing slides one edge of an image along the X or Y axis, creating a parallelogram. An X direction shear slides an edge along the X axis, while a Y direction shear slides an edge along the Y axis. The amount of the shear is controlled by a shear angle. For X direction shears, x_shear is measured relative to the Y axis, and similarly, for Y direction shears y_shear is measured relative to the X axis. Empty triangles left over from shearing the image are filled with the background color defined by member 'background_color' of the image.. ShearImage() allocates the memory necessary for the new Image structure and returns a pointer to the new image.

ShearImage() is based on the paper "A Fast Algorithm for General Raster Rotatation" by Alan W. Paeth.

The format of the ShearImage method is:

    Image *ShearImage(const Image *image,const double x_shear,
      const double y_shear,ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

x_shear, y_shear

Specifies the number of degrees to shear the image.

exception

return any errors or warnings in this structure.

## ShearRotateImage

ShearRotateImage() 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. ShearRotateImage allocates the memory necessary for the new Image structure and returns a pointer to the new image.

ShearRotateImage() is based on the paper "A Fast Algorithm for General Raster Rotatation" by Alan W. Paeth. ShearRotateImage is adapted from a similar method based on the Paeth paper written by Michael Halle of the Spatial Imaging Group, MIT Media Lab.

The format of the ShearRotateImage method is:

    Image *ShearRotateImage(const Image *image,const double degrees,
      ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

degrees

Specifies the number of degrees to rotate the image.

exception

return any errors or warnings in this structure.