$driver = empty($conf['image']['convert']) ? 'gd' : 'im';
$img = Ansel::getImageObject();
try {
- $result = $img->loadFile($info['image']['file']);
+ $img->loadFile($info['image']['file']);
+ $dimensions = $img->getDimensions();
} catch (Horde_Image_Exception $e) {
$notification->push($e->getMessage());
header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
exit;
}
- $dimensions = $img->getDimensions();
if ($dimensions['width'] < 50 || $dimensions['height'] < 50) {
$notification->push(_("Photo is too small. Search photo must be at least 50x50 pixels."));
header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
exit;
}
- $result = $img->resize(min($conf['screen']['width'], $dimensions['width']),
- min($conf['screen']['height'], $dimensions['height']));
- if (is_a($result, 'PEAR_Error')) {
- $notification->push($result->getMessage());
+ try {
+ $img->resize(min($conf['screen']['width'], $dimensions['width']),
+ min($conf['screen']['height'], $dimensions['height']));
+ } catch (Horde_Image_Exception $e) {
+ $notification->push($e->getMessage());
header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
exit;
}
}
/* Crop image. */
-$result = $img->crop($x1, $y1, $x2, $y2);
-if (is_a($result, 'PEAR_Error')) {
- $notification->push($result->getMessage());
+try {
+ $result = $img->crop($x1, $y1, $x2, $y2);
+} catch (Horde_Image_Exception $e) {
+ $notification->push($e->getMessage());
header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
exit;
}
/* Resize image. */
-$img->getDimensions();
-if ($img->_width >= 50) {
- $img->resize(min(50, $img->_width), min(50, $img->_height), true);
+try {
+ $img->getDimensions();
+ if ($img->_width >= 50) {
+ $img->resize(min(50, $img->_width), min(50, $img->_height), true);
+ }
+} catch (Horde_Image_Exception $e) {
+ $notification->push($e->getMessage());
+ header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
}
/* Save image. */
$params = array_merge(array('type' => $conf['image']['type'],
'context' => $context),
$params);
+ //@TODO: get around to updating horde/config/conf.xml to include the imagick driver
$driver = empty($conf['image']['convert']) ? 'Gd' : 'Im';
return Horde_Image::factory($driver, $params);
}
Horde::logMessage($data, __FILE__, __LINE__, PEAR_LOG_ERR);
return $data;
}
-
- if (is_a($result = $this->_image->loadString($this->getVFSPath('full') . '/' . $this->id, $data), 'PEAR_Error')) {
- return $result;
- }
+ $this->_image->loadString($this->getVFSPath('full') . '/' . $this->id, $data);
$styleDef = Ansel::getStyleDefinition($style);
if ($view == 'prettythumb') {
$viewType = $styleDef['thumbstyle'];
/* Flag to determine if we need to resave the image data */
$needUpdate = false;
- /* Populate any local properties that come from EXIF */
- if (!is_a($exif_fields, 'PEAR_Error')) {
- /* Save any geo data to a seperate table as well */
- if (!empty($exif_fields['GPSLatitude'])) {
- $this->lat = $exif_fields['GPSLatitude'];
- $this->lng = $exif_fields['GPSLongitude'];
- $this->geotag_timestamp = time();
- $needUpdate = true;
- }
+ /* Populate any local properties that come from EXIF
+ * Save any geo data to a seperate table as well */
+ if (!empty($exif_fields['GPSLatitude'])) {
+ $this->lat = $exif_fields['GPSLatitude'];
+ $this->lng = $exif_fields['GPSLongitude'];
+ $this->geotag_timestamp = time();
+ $needUpdate = true;
+ }
- if (!empty($exif_fields['DateTimeOriginal'])) {
- $this->originalDate = $exif_fields['DateTimeOriginal'];
- $needUpdate = true;
- }
+ if (!empty($exif_fields['DateTimeOriginal'])) {
+ $this->originalDate = $exif_fields['DateTimeOriginal'];
+ $needUpdate = true;
+ }
- /* Attempt to autorotate based on Orientation field */
- $this->_autoRotate();
+ /* Attempt to autorotate based on Orientation field */
+ $this->_autoRotate();
- /* Save attributes. */
- $insert = $GLOBALS['ansel_db']->prepare('INSERT INTO ansel_image_attributes (image_id, attr_name, attr_value) VALUES (?, ?, ?)');
- foreach ($exif_fields as $name => $value) {
- $result = $insert->execute(array($this->id, $name, Horde_String::convertCharset($value, Horde_Nls::getCharset(), $GLOBALS['conf']['sql']['charset'])));
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
- /* Cache it locally */
- $this->_exif[$name] = Horde_Image_Exif::getHumanReadable($name, $value);
+ /* Save attributes. */
+ $insert = $GLOBALS['ansel_db']->prepare('INSERT INTO ansel_image_attributes (image_id, attr_name, attr_value) VALUES (?, ?, ?)');
+ foreach ($exif_fields as $name => $value) {
+ $result = $insert->execute(array($this->id, $name, Horde_String::convertCharset($value, Horde_Nls::getCharset(), $GLOBALS['conf']['sql']['charset'])));
+ if (is_a($result, 'PEAR_Error')) {
+ return $result;
}
- $insert->free();
+ /* Cache it locally */
+ $this->_exif[$name] = Horde_Image_Exif::getHumanReadable($name, $value);
}
+ $insert->free();
+
return $needUpdate;
}
return $result;
}
- return $this->_image->display();
+ $this->_image->display();
}
/**
{
$this->load($view);
$this->_dirty = true;
- return $this->_image->rotate($angle);
+ $this->_image->rotate($angle);
}
function crop($x1, $y1, $x2, $y2)
{
$this->_dirty = true;
- return $this->_image->crop($x1, $y1, $x2, $y2);
+ $this->_image->crop($x1, $y1, $x2, $y2);
}
/**
{
$this->load($view);
$this->_dirty = true;
- return $this->_image->grayscale();
+ $this->_image->grayscale();
}
/**
$params['font'] = $GLOBALS['conf']['image']['font'];
}
$this->_image->addEffect('TextWatermark', $params);
-
- return true;
}
/**
{
$this->load($view);
$this->_dirty = true;
- return $this->_image->flip();
+ $this->_image->flip();
}
/**
{
$this->load($view);
$this->_dirty = true;
- return $this->_image->mirror();
+ $this->_image->mirror();
}
/**
{
if (!empty($this->_image)) {
$this->_dimensions = $this->_image->_image->getDimensions();
- if (is_a($this->_dimensions, 'PEAR_Error')) {
- Horde::logMessage($this->_dimensions, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $this->_dimensions;
- }
}
return $this->_create();
}
function _create()
{
- return $this->_image->_image->resize(min(50, $this->_dimensions['width']),
- min(50, $this->_dimensions['height']),
- true);
+ $this->_image->_image->resize(min(50, $this->_dimensions['width']),
+ min(50, $this->_dimensions['height']),
+ true);
+
+ return true;
}
}
} else {
$styleDef = Ansel::getStyleDefinition($this->_style);
}
- $res = $this->_image->_image->addEffect('PolaroidImage',
- array('background' => $styleDef['background'],
- 'padding' => 5));
- if (is_a($res, 'PEAR_Error')) {
- Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
+ $this->_image->_image->addEffect('PolaroidImage',
+ array('background' => $styleDef['background'],
+ 'padding' => 5));
+
+ $this->_image->_image->applyEffects();
- return $this->_image->_image->applyEffects();
+ return true;
}
}
function _create()
{
- return $this->_image->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['screen']['height'], $this->_dimensions['height']),
- true);
+ $this->_image->_image->resize(min($GLOBALS['conf']['screen']['width'], $this->_dimensions['width']),
+ min($GLOBALS['conf']['screen']['height'], $this->_dimensions['height']),
+ true);
+
+ return true;
}
}
$res = $this->_image->_image->addEffect(
'border', array('bordercolor' => '#333'));
- $res = $this->_image->_image->addEffect('DropShadow',
- array('background' => $styleDef['background'],
- 'padding' => 5,
- 'distance' => '8',
- 'fade' => 2));
-
- if (is_a($res, 'PEAR_Error')) {
- Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
+ $this->_image->_image->addEffect('DropShadow',
+ array('background' => $styleDef['background'],
+ 'padding' => 5,
+ 'distance' => '8',
+ 'fade' => 2));
+
+ $this->_image->_image->applyEffects();
- return $this->_image->_image->applyEffects();
+ return true;
}
}
function _create()
{
- return $this->_image->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
- true);
+ $this->_image->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
+ min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
+ true);
+
+ return true;
}
}