You are here

function imagecache_autorotate_effect in ImageCache Actions 8

Same name and namespace in other branches
  1. 7 autorotate/imagecache_autorotate.module \imagecache_autorotate_effect()

Autorotate image based on EXIF Orientation tag.

1 string reference to 'imagecache_autorotate_effect'
imagecache_autorotate_image_effect_info in autorotate/imagecache_autorotate.module
Implements hook_image_effect_info().

File

autorotate/imagecache_autorotate.module, line 100
Autorotate image based on EXIF Orientation tag.

Code

function imagecache_autorotate_effect(stdClass $image) {

  // Test to see if EXIF is supported by the current image type.
  if (in_array($image->info['mime_type'], array(
    'image/jpeg',
    'image/tiff',
  ))) {

    // Hand over to toolkit.
    return image_toolkit_invoke('imagecache_autorotate', $image);
  }
  else {
    if ($image->source === 'modules/image/sample.png' && user_access('administer image styles')) {
      if (!extension_loaded('exif')) {

        // Issue a warning if we are in the admin screen and the exif extension is
        // not enabled.
        drupal_set_message(t('The autorotate image effect requires the exif extension to be enabled.'), 'warning');
        if ($image->toolkit === 'imagemagick') {
          drupal_set_message(t('Though imagemagick will work without the exif extension, subsequent effects may fail as the image dimensions cannot be updated.'), 'warning');
        }
      }
    }
  }
  return TRUE;
}