/** * Returns an appropriate Horde_Image object based on Horde's configuration. * * @param array $params An array of image parameters. @see * Horde_Image_Base * * @return Horde_Image * @throws Horde_Exception */ public function create(array $params = array()) { global $conf; $driver = $conf['image']['driver']; $class = $this->_getDriverName($driver, 'Horde_Image'); $context = array('tmpdir' => Horde::getTempdir(), 'logger' => $this->_injector->getInstance('Horde_Log_Logger')); switch ($driver) { case 'Im': $context['convert'] = $conf['image']['convert']; $context['identify'] = $conf['image']['identify']; break; } return new $class($params, $context); }
<?php /** * @package Image */ require_once __DIR__ . '/../lib/Application.php'; Horde_Registry::appInit('horde', array('authentication' => 'none', 'session_control' => 'none')); $image = new Horde_Image_Svg(array('height' => 400, 'width' => 400), array('tmpdir' => Horde::getTempdir())); $image->rectangle(30, 30, 100, 60, 'black', 'yellow'); $image->roundedRectangle(30, 30, 100, 60, 15, 'black', 'red'); $image->circle(30, 30, 30, 'black', 'blue'); $image->polygon(array(array('x' => 30, 'y' => 50), array('x' => 40, 'y' => 60), array('x' => 50, 'y' => 40)), 'green', 'green'); $image->arc(100, 100, 100, 0, 70, 'black', 'green'); $image->brush(100, 300, 'red', 'circle'); $image->line(0, 200, 500, 200, 'darkblue', 2); $image->line(200, 200, 200, 500, 'darkblue', 2); $image->polyline(array(array('x' => 130, 'y' => 150), array('x' => 140, 'y' => 160), array('x' => 150, 'y' => 140)), 'black', 5); $image->text('Hello World', 100, 100, 'arial', 'purple'); $image->display();
/** * Obtain a Horde_Image object * * @param array $params Any additional parameters * * @return Horde_Image_Base The image object. */ function getImageObject($params = array()) { global $convert, $driver, $identify; $context = array('tmpdir' => Horde::getTempdir()); if ($driver == 'Im') { $context['convert'] = $convert; $context['identify'] = $identify; } // Use the default $class = 'Horde_Image_' . $driver; if (class_exists($class)) { return new $class($params, $context); } throw new Horde_Exception('Invalid Image driver specified: ' . $class . ' not found.'); }