예제 #1
0
 /**
  * Returns binary string with image data in format specified by $format
  * 
  * Additional parameters may be passed to the function. See GDImage_Image::saveToFile() for more details.
  * 
  * @param string $format The format of the image
  * @return string The binary image data in specified format
  */
 function asString($format)
 {
     ob_start();
     $args = func_get_args();
     $args[0] = null;
     array_unshift($args, $this->getHandle());
     $mapper = GDImage_MapperFactory::selectMapper(null, $format);
     call_user_func_array(array($mapper, 'save'), $args);
     return ob_get_clean();
 }
예제 #2
0
 /**
  * Create and load an image from a file or URL. You can override the file 
  * format by specifying the second parameter.
  * 
  * @param string $uri File or url
  * @param string $format *DEPRECATED* Format hint, usually not needed
  * @return GDImage_Image GDImage_PaletteImage or GDImage_TrueColorImage instance
  */
 static function loadFromFile($uri, $format = null)
 {
     $data = file_get_contents($uri);
     $handle = @imagecreatefromstring($data);
     if (!self::isValidImageHandle($handle)) {
         $mapper = GDImage_MapperFactory::selectMapper($uri, $format);
         $handle = $mapper->load($uri);
     }
     if (!self::isValidImageHandle($handle)) {
         JError::raiseError(500, JText::_('JLIB_GDIMAGE_ERROR_INVALID_SOURCE') . ' ' . $uri);
         return false;
     }
     return self::loadFromHandle($handle);
 }