Ticket #597: ImageMagick.diff
| File ImageMagick.diff, 1.3 kB (added by tterragcnoom, 4 months ago) |
|---|
-
(clipboard)
old new 53 53 * Creates a temporary image and executes the given actions. By creating a 54 54 * temporary copy of the image before manipulating it, this process is atomic. 55 55 */ 56 public function process($image, $actions, $dir, $file )56 public function process($image, $actions, $dir, $file, $output = FALSE) 57 57 { 58 58 // We only need the filename 59 59 $image = $image['file']; … … 72 72 73 73 // All calls to these will need to be escaped, so do it now 74 74 $this->cmd_image = escapeshellarg($this->tmp_image); 75 $this->new_image = escapeshellarg($dir.$file);75 $this->new_image = ($output)?$this->cmd_image:escapeshellarg($dir.$file); 76 76 77 77 if ($status = $this->execute($actions)) 78 78 { … … 82 82 if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -quality '.$quality.'% '.$this->cmd_image.' '.$this->new_image)) 83 83 { 84 84 $this->errors[] = $error; 85 }else{ 86 if ($output != FALSE){ 87 $contents = file_get_contents($this->tmp_image); 88 switch (substr($file, strrpos($file, '.') + 1)) 89 { 90 case 'jpg': 91 case 'jpeg': 92 header ("Content-Type: image/jpeg"); 93 break; 94 case 'gif': 95 header ("Content-Type: image/gif"); 96 break; 97 case 'png': 98 header ("Content-Type: image/png"); 99 break; 100 } 101 echo ($contents); 102 } 85 103 } 86 104 } 87 105
