예제 #1
0
 /**
  * Outputs the image to browser
  * 
  * Sets headers Content-length and Content-type, and echoes the image in the specified format.
  * All other headers (such as Content-disposition) must be added manually. 
  * 
  * @param string $format Image format
  */
 function output($format)
 {
     $args = func_get_args();
     $data = call_user_func_array(array($this, 'asString'), $args);
     $this->writeHeader('Content-length', strlen($data));
     $this->writeHeader('Content-type', GDImage_MapperFactory::mimeType($format));
     echo $data;
 }
예제 #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);
 }