diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-03-18 19:53:56 +1100 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-03-18 19:53:56 +1100 |
| commit | c136d44894adaf5d81ebadb8a70f1f456232204f (patch) | |
| tree | 72302070afa61810848f87524af962f7ef21961b /inc/image.php | |
| parent | fb5fc0459906513fcc96bfb506ee13a949782ca8 (diff) | |
Better upload handling (don't move file before handling it)
Diffstat (limited to 'inc/image.php')
| -rw-r--r-- | inc/image.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/inc/image.php b/inc/image.php index 63d6f9b5..9275bd9c 100644 --- a/inc/image.php +++ b/inc/image.php @@ -216,8 +216,7 @@ public function init() { global $config; - $this->temp = tempnam($config['tmp'], 'imagick'); - + $this->temp = false; } public function from() { $size = trim(shell_exec('identify -format "%w %h" ' . escapeshellarg($this->src . '[0]'))); @@ -232,8 +231,13 @@ } } public function to($src) { - rename($this->temp, $src); - chmod($src, 0664); + if(!$this->temp) { + // $config['redraw_image'] + shell_exec('convert ' . escapeshellarg($this->src) . ' ' . escapeshellarg($src)); + } else { + rename($this->temp, $src); + chmod($src, 0664); + } } public function width() { return $this->width; @@ -243,10 +247,18 @@ } public function destroy() { @unlink($this->temp); + $this->temp = false; } public function resize() { global $config; + if($this->temp) { + // remove old + $this->destroy(); + } + + $this->temp = tempnam($config['tmp'], 'imagick'); + $quality = $config['thumb_quality'] * 10; if(shell_exec("convert -flatten -filter Point -scale {$this->width}x{$this->height} +antialias -quality {$quality} " . escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp)) |
