Obtain a Horde_Image object
public static getImageObject ( array $params = [] ) : Horde_Image | ||
$params | array | Any additional parameters |
return | Horde_Image | object |
/** * * @return Horde_Image */ protected function _create() { $imgobjs = $this->_getStackImages(); $style = $this->_params['style']; $params = array('width' => 100, 'height' => 100, 'background' => $style->background); $baseImg = Ansel::getImageObject($params); try { $baseImg->addEffect('PhotoStack', array('images' => $imgobjs, 'resize_height' => $GLOBALS['conf']['thumbnail']['height'], 'padding' => 0, 'background' => $style->background, 'type' => 'rounded')); $baseImg->applyEffects(); $baseImg->resize($GLOBALS['conf']['thumbnail']['width'], $GLOBALS['conf']['thumbnail']['height']); } catch (Horde_Image_Exception $e) { throw new Ansel_Exception($e); } return $baseImg; }
/** * Get a Horde_Image object representing the requested face. * * @param integer $face_id The requested face_id * * @return Horde_Image The requested Horde_Image object * @throws Ansel_Exception */ public function getFaceImageObject($face_id) { $face = $this->getFaceById($face_id, true); // Load the image for this face if (!$this->viewExists($face['image_id'], $face_id, true)) { throw new Ansel_Exception(sprintf("Unable to create or locate face_id %u", $face_id)); } $vfspath = Ansel_Faces::getVFSPath($face['image_id']) . 'faces'; $vfsname = $face_id . Ansel_Faces::getExtension(); $img = Ansel::getImageObject(); try { $data = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->read($vfspath, $vfsname); } catch (Horde_Vfs_Exception $e) { throw new Ansel_Exception($e); } $img->loadString($data); return $img; }
* * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.horde.org/licenses/gpl. * * @author Duck <*****@*****.**> */ require_once 'tabs.php'; /* Search from */ $form = new Horde_Form($vars); $msg = _("Please upload photo with the face to search for. You can search only one face at a time."); $form->addVariable(_("Face to search for"), 'image', 'file', true, false, $msg, array(false)); $form->setButtons(_("Upload")); if ($form->validate()) { $form->getInfo(null, $info); $tmp = Horde::getTempDir(); $img = Ansel::getImageObject(); try { $img->loadFile($info['image']['file']); $dimensions = $img->getDimensions(); } catch (Horde_Image_Exception $e) { $notification->push($e->getMessage()); Horde::url('faces/search/image.php')->redirect(); exit; } if ($dimensions['width'] < 50 || $dimensions['height'] < 50) { $notification->push(_("Photo is too small. Search photo must be at least 50x50 pixels.")); Horde::url('faces/search/image.php')->redirect(); exit; } try { $img->resize(min($conf['screen']['width'], $dimensions['width']), min($conf['screen']['height'], $dimensions['height']));
/** * Const'r * * @param array $image * * @return Ansel_Image */ public function __construct(array $image = array()) { if ($image) { $this->filename = $image['image_filename']; if (!empty($image['gallery_id'])) { $this->gallery = $image['gallery_id']; } if (!empty($image['image_caption'])) { $this->caption = $image['image_caption']; } if (isset($image['image_sort'])) { $this->sort = $image['image_sort']; } if (!empty($image['image_id'])) { $this->id = $image['image_id']; } if (!empty($image['data'])) { $this->_data['full'] = $image['data']; } if (!empty($image['image_uploaded_date'])) { $this->uploaded = $image['image_uploaded_date']; } else { $this->uploaded = time(); } if (!empty($image['image_type'])) { $this->type = $image['image_type']; } if (!empty($image['tags'])) { $this->_tags = $image['tags']; } if (!empty($image['image_faces'])) { $this->facesCount = $image['image_faces']; } $this->location = !empty($image['image_location']) ? $image['image_location'] : ''; // The following may have to be rewritten by EXIF. // EXIF requires both an image id and a stream, so we can't // get EXIF data before we save the image to the VFS. if (!empty($image['image_original_date'])) { $this->originalDate = $image['image_original_date']; } else { $this->originalDate = $this->uploaded; } $this->lat = !empty($image['image_latitude']) ? $image['image_latitude'] : ''; $this->lng = !empty($image['image_longitude']) ? $image['image_longitude'] : ''; $this->geotag_timestamp = !empty($image['image_geotag_date']) ? $image['image_geotag_date'] : '0'; } $this->_image = Ansel::getImageObject(); $this->_image->reset(); $this->id = !empty($image['image_id']) ? $image['image_id'] : null; }
/** * Check to see if a particular image manipulation function is * available. * * @param string $feature The name of the function. * * @return boolean True if the function is available. */ public static function isAvailable($feature) { static $capabilities; // If the administrator locked auto watermark on, disable user // intervention if ($feature == 'text_watermark' && $GLOBALS['prefs']->getValue('watermark_auto') && $GLOBALS['prefs']->isLocked('watermark_auto')) { return false; } if (!isset($capabilities)) { $im = Ansel::getImageObject(); $capabilities = array_merge($im->getCapabilities(), $im->getLoadedEffects()); } return in_array($feature, $capabilities); }