diff --git a/includes/utilities.inc b/includes/utilities.inc index 44a80402..d858ff0c 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -943,3 +943,41 @@ function islandora_event_status() { $text = ($results) ? t('The status messages above will be deleted after viewing this page.') : t('No messages to display.'); return array('#markup' => $text); } + +/** + * Scales the given image. + * + * @param object $file + * The image file to scale. + * @param int $width + * The width to scale the derived image to. + * @param int $height + * The height to scale the derived image to. + * + * @return bool + * TRUE if successful, FALSE otherwise. + */ +function islandora_scale_thumbnail($file, $width, $height) { + $real_path = drupal_realpath($file->uri); + $image = image_load($real_path); + try { + if (!empty($image)) { + $scale = image_scale($image, $width, $height, TRUE); + if ($scale) { + return image_save($image); + } + } + } + catch (exception $e) { + drupal_set_message(t( + "Islandora failed to scale image with message: '@message'", + array("@message" => $e->getMessage()))); + watchdog( + 'islandora', + 'Islandora failed to scale image.
With stack: @trace', + array('@trace' => $e->getTraceAsString()), + WATCHDOG_ERROR + ); + } + return FALSE; +} diff --git a/islandora.info b/islandora.info index 36ed0dff..732143b5 100644 --- a/islandora.info +++ b/islandora.info @@ -1,6 +1,8 @@ name = Islandora description = "View and manage Fedora objects" package = Islandora +dependencies[] = image +dependencies[] = file version = 7.x-dev core = 7.x configure = admin/islandora/configure