You are here

function image_imagemagick_rotate in ImageMagick 7

Rotates an image the given number of degrees.

Parameters

$image: An image object. The $image->resource, $image->info['width'], and $image->info['height'] values will be modified by this call.

$degrees: The number of (clockwise) degrees to rotate the image.

$background: An hexadecimal integer specifying the background color to use for the uncovered area of the image after the rotation. E.g. 0x000000 for black, 0xff00ff for magenta, and 0xffffff for white. For images that support transparency, this will default to transparent. Otherwise it will be white.

Return value

TRUE or FALSE, based on success.

See also

image_rotate()

File

./imagemagick.module, line 230
Provides ImageMagick integration.

Code

function image_imagemagick_rotate(stdClass $image, $degrees, $background = NULL) {
  if (!isset($background)) {
    $background = 'transparent';
  }
  elseif (is_int($background)) {
    $background = '#' . str_pad(dechex($background), 6, 0, STR_PAD_LEFT);
  }
  else {
    $background = strtr($background, array(
      '0x' => '#',
    ));
  }
  $image->ops[] = '-background ' . escapeshellarg($background) . ' -rotate ' . (double) $degrees;
  return TRUE;
}