Example #1
0
 /**
  * Runs [self::check] and loads the image.
  *
  * @param   string  $file  image file path
  * @return  void
  * @throws  ErrorException
  */
 public function __construct($file)
 {
     if (!self::$_checked) {
         // Run the install check
         self::check();
     }
     parent::__construct($file);
     // Set the image creation function name
     switch ($this->type) {
         case IMAGETYPE_JPEG:
             $create = 'imagecreatefromjpeg';
             break;
         case IMAGETYPE_GIF:
             $create = 'imagecreatefromgif';
             break;
         case IMAGETYPE_PNG:
             $create = 'imagecreatefrompng';
             break;
     }
     if (!isset($create) or !function_exists($create)) {
         throw new ErrorException('Installed GD does not support :type images', array(':type' => image_type_to_extension($this->type, FALSE)));
     }
     // Save function for future use
     $this->_create_function = $create;
     // Save filename for lazy loading
     $this->_image = $this->file;
 }
Example #2
0
 /**
  * Runs [self::check] and loads the image.
  *
  * @return  void
  * @throws  ErrorException
  */
 public function __construct($file)
 {
     if (!self::$_checked) {
         // Run the install check
         self::check();
     }
     parent::__construct($file);
     $this->im = new Imagick();
     $this->im->readImage($file);
     if (!$this->im->getImageAlphaChannel()) {
         // Force the image to have an alpha channel
         $this->im->setImageAlphaChannel(Imagick::ALPHACHANNEL_SET);
     }
 }