Esempio n. 1
0
 public function load($filename, $return_data = false, $force_extension = false)
 {
     extract(parent::load($filename, $return_data, $force_extension));
     $return = false;
     $image_extension == 'jpg' and $image_extension = 'jpeg';
     if (!$return_data) {
         $this->image_data !== null and imagedestroy($this->image_data);
         $this->image_data = null;
     }
     // Check if the function exists
     if (function_exists('imagecreatefrom' . $image_extension)) {
         // Create a new transparent image.
         $sizes = $this->sizes($image_fullpath);
         $tmpImage = call_user_func('imagecreatefrom' . $image_extension, $image_fullpath);
         $image = $this->create_transparent_image($sizes->width, $sizes->height, $tmpImage);
         if (!$return_data) {
             $this->image_data = $image;
             $return = true;
         } else {
             $return = $image;
         }
         $this->debug('', "<strong>Loaded</strong> <code>" . $image_fullpath . "</code> with size of " . $sizes->width . "x" . $sizes->height);
     } else {
         throw new \RuntimeException("Function imagecreatefrom" . $image_extension . "() does not exist (Missing GD?)");
     }
     return $return_data ? $return : $this;
 }
Esempio n. 2
0
 public function load($filename, $return_data = false, $force_extension = false)
 {
     extract(parent::load($filename, $return_data, $force_extension));
     if ($this->imagick == null) {
         $this->imagick = new \Imagick();
     }
     $this->imagick->readImage($filename);
     return $this;
 }
Esempio n. 3
0
 public function load($filename, $return_data = false, $force_extension = false)
 {
     extract(parent::load($filename, $return_data, $force_extension));
     $this->clear_sizes();
     if (empty($this->image_temp)) {
         do {
             $this->image_temp = $this->config['temp_dir'] . substr($this->config['temp_append'] . md5(time() * microtime()), 0, 32) . '.png';
         } while (file_exists($this->image_temp));
     } elseif (file_exists($this->image_temp)) {
         $this->debug('Removing previous temporary image.');
         unlink($this->image_temp);
     }
     $this->debug('Temp file: ' . $this->image_temp);
     if (!file_exists($this->config['temp_dir']) || !is_dir($this->config['temp_dir'])) {
         throw new \RuntimeException("The temp directory that was given does not exist.");
     } elseif (!touch($this->config['temp_dir'] . $this->config['temp_append'] . '_touch')) {
         throw new \RuntimeException("Could not write in the temp directory.");
     }
     $this->exec('convert', '"' . $image_fullpath . '"[0] "' . $this->image_temp . '"');
     return $this;
 }