if ($data instanceof PEAR_Error) {
throw new Horde_Exception_Prior($data);
}
- $img->loadString($face_id, $data);
+ $img->loadString($data);
return $img;
}
// already have the full data loaded. If we auto-rotate the image
// then there is no need to save it just to load it again.
if ($view == 'full' && !empty($this->_data['full'])) {
- $this->_image->loadString('original', $this->_data['full']);
+ $this->_image->loadString($this->_data['full']);
$this->_loaded['full'] = true;
return true;
}
return;
}
- /* We've definitely successfully loaded the image now. */
- $this->_loaded[$viewHash] = true;
-
/* Get the VFS info. */
$vfspath = $this->getVFSPath($view, $style);
throw new Ansel_Exception($data);
}
+ /* We've definitely successfully loaded the image now. */
+ $this->_loaded[$viewHash] = true;
$this->_data[$viewHash] = $data;
- $this->_image->loadString($vfspath . '/' . $this->id, $data);
+ $this->_image->loadString($data);
+
return true;
}
Horde::logMessage($data, __FILE__, __LINE__, PEAR_LOG_ERR);
throw new Ansel_Exception($data);
}
- $this->_image->loadString($this->getVFSPath('full') . '/' . $this->id, $data);
+
+ $vHash = $this->getViewHash($view, $style);
+ $this->_image->loadString($data);
$styleDef = Ansel::getStyleDefinition($style);
if ($view == 'prettythumb') {
$viewType = $styleDef['thumbstyle'];
$iview->create();
/* Cache the data from the new imageview */
- $view = $this->getViewHash($view, $style);
try {
- $this->_data[$view] = $this->_image->raw();
+ $this->_data[$vHash] = $this->_image->raw();
} catch (Horde_Image_Exception $e) {
throw new Ansel_Exception($e);
}
/* ...and put it in Horde_Image obejct, then save */
- $this->_image->loadString($vfspath . '/' . $this->id, $this->_data[$view]);
- $this->_loaded[$view] = true;
- $GLOBALS['ansel_vfs']->writeData($vfspath, $this->getVFSName($view), $this->_data[$view], true);
+ $this->_image->loadString($this->_data[$vHash]);
+ $this->_loaded[$vHash] = true;
+ $GLOBALS['ansel_vfs']->writeData($vfspath, $this->getVFSName($vHash), $this->_data[$vHash], true);
/* Autowatermark the screen view */
if ($view == 'screen' &&
try {
$this->_image->addEffect($type, $params);
} catch (Horde_Image_Exception $e) {
- Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
throw new Ansel_Exception($e);
}
}
protected $_data = '';
/**
- * The current image id.
- *
- * @TODO: Do we *really* need an image id...and if so, we can make the
- * parameter optional in the methods that take one?
- *
- * @var string
- */
- protected $_id = '';
-
- /**
* Logger
*/
protected $_logger;
public function reset()
{
$this->_data = '';
- $this->_id = '';
$this->_width = null;
$this->_height = null;
$this->_background = 'white';
* @param string $id An arbitrary id for the image.
* @param string $image_data The data to use for the image.
*/
- public function loadString($id, $image_data)
+ public function loadString($image_data)
{
- if ($id != $this->_id) {
- $this->reset();
- $this->_data = $image_data;
- $this->_id = $id;
- }
+ $this->reset();
+ $this->_data = $image_data;
}
/**
*/
public function loadFile($filename)
{
- if ($filename != $this->_id) {
- $this->reset();
- if (!file_exists($filename)) {
- throw new Horde_Image_Exception(sprintf("The image file, %s, does not exist.", $filename));
- }
- if ($this->_data = file_get_contents($filename)) {
- $this->_id = $filename;
- } else {
- throw new Horde_Image_Exception(sprintf("Could not load the image file %s", $filename));
- }
+ $this->reset();
+ if (!file_exists($filename)) {
+ throw new Horde_Image_Exception(sprintf("The image file, %s, does not exist.", $filename));
+ }
+ if (!$this->_data = file_get_contents($filename)) {
+ throw new Horde_Image_Exception(sprintf("Could not load the image file %s", $filename));
}
return true;
$context = array('tmpdir' => $this->_image->getTmpDir());
$size = $image->getImageGeometry();
$new = Horde_Image::factory('Imagick', array('context' => $context));
- $new->loadString('somestring', $image->getImageBlob());
+ $new->loadString($image->getImageBlob());
$image->destroy();
$new->addEffect('RoundCorners', array('border' => 2, 'bordercolor' => '#111'));
$new->applyEffects();
* @param string $id An arbitrary id for the image.
* @param string $image_data The data to use for the image.
*/
- public function loadString($id, $image_data)
+ public function loadString($image_data)
{
- if ($id != $this->_id) {
- $this->_im = $this->_call('imageCreateFromString', array($image_data));
- $this->_id = $id;
- }
+ $this->_im = $this->_call('imageCreateFromString', array($image_data));
}
/**
if (!empty($params['filename'])) {
$this->loadFile($params['filename']);
} elseif (!empty($params['data'])) {
- $this->loadString(md5($params['data']), $params['data']);
+ $this->loadString($params['data']);
} else {
$cmd = "-size {$this->_width}x{$this->_height} xc:{$this->_background} +profile \"*\" {$this->_type}:__FILEOUT__";
$this->executeConvertCmd($cmd);
if (!empty($params['filename'])) {
$this->loadFile($params['filename']);
} elseif(!empty($params['data'])) {
- $this->loadString(md5($params['data']), $params['data']);
+ $this->loadString($params['data']);
} else {
$this->_width = max(array($this->_width, 1));
$this->_height = max(array($this->_height, 1));
*
* @return void
*/
- public function loadString($id, $image_data)
+ public function loadString($image_data)
{
- parent::loadString($id, $image_data);
+ parent::loadString($image_data);
$this->_imagick->clear();
try {
$this->_imagick->readImageBlob($image_data);
$context['identify'] = $conf['image']['identify'];
}
$image = Horde_Image::factory($driver, array('context' => $context));
-$image->loadString($file, $file_data);
+$image->loadString($file_data);
/* Check if no editing action required and send the image to browser. */
if (empty($action)) {
if ($load) {
try {
- $ret = $img->loadString(1, $this->_mimepart->getContents());
+ $ret = $img->loadString($this->_mimepart->getContents());
} catch (Horde_Image_Exception $e) {
return false;
}
if ($load) {
try {
- $ret = $img->loadString(1, $this->_mimepart->getContents());
+ $ret = $img->loadString($this->_mimepart->getContents());
} catch (Horde_Image_Exception $e) {
return false;
}