/** * Create and cache the view. * * @return mixed Views used as gallery key images return Horde_Image, * other views return boolean */ public function create() { if (!empty($this->_image)) { // Make sure to load the image. $this->_image->load('full'); $img = $this->_image->getHordeImage(); $this->_dimensions = $img->getDimensions(); } return $this->_create(); }
/** * Create a face image from the given data. * * @param integer $face_id Face id to generate * @param Ansel_Image $image Image face belongs to * @param integer $x1 The top left corner of the cropped image. * @param integer $y1 The top right corner of the cropped image. * @param integer $x2 The bottom left corner of the cropped image. * @param integer $y2 The bottom right corner of the cropped image. * * @throws Ansel_Exception */ public function createView($face_id, Ansel_Image $image, $x1, $y1, $x2, $y2) { // Make sure the image data is fresh $image->load('screen'); // Crop to the face try { $image->crop($x1, $y1, $x2, $y2); } catch (Horde_Image_Exception $e) { throw new Ansel_Exception($e->getMessage()); } // Resize and save $ext = Ansel_Faces::getExtension(); $path = Ansel_Faces::getVFSPath($image->id); $image->resize(50, 50, false); try { $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->writeData($path . 'faces', $face_id . $ext, $image->raw(), true); } catch (Horde_Vfs_Exception $e) { throw new Ansel_Exception($e); } }