source_path = $source; if (isset($conf['imagick_dir'])) $this->imagemagickdir = rtrim($conf['imagick_dir'], ' /\\').'/'; $command = $this->imagemagickdir.'identify -format "%wx%h" "'.realpath($this->source_path).'"'; @exec($command, $returnarray, $returnvalue); if($returnvalue or !preg_match('/^(\d+)x(\d+)$/', $returnarray[0], $match)) { die("[External ImageMagick] Corrupt image"); } $this->width = $match[1]; $this->height = $match[2]; } function add_command($command, $params=null) { $this->commands[$command] = $params; } function getImageWidth() { return $this->width; } function getImageHeight() { return $this->height; } function setImageCompressionQuality($quality) { $this->add_command('quality', $quality); } function setInterlaceScheme($interlace) { $this->add_command('interlace', $interlace); } function resizeImage($width, $height, $filter, $blur) { $this->add_command('resize', $width.'x'.$height.'!'); $this->add_command('filter', $filter); //$this->add_command('blur', $blur); } function stripImage() { $this->add_command('strip'); } function rotateImage($background, $rotate) { $this->add_command('rotate', $rotate); } function setImageOrientation($orientation) { $this->add_command('orient', $orientation); } function cropImage($width, $height, $x, $y) { $this->add_command('crop', $width.'x'.$height.'+'.$x.'+'.$y); } function writeImage($destination_filepath) { global $conf; $exec = $this->imagemagickdir.'convert'; $exec .= ' "'.realpath($this->source_path).'"'; foreach ($this->commands as $command => $params) { $exec .= ' -'.$command; if (!empty($params)) { $exec .= ' '.$params; } } $dest = pathinfo($destination_filepath); $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; @exec($exec, $returnarray, $returnvalue); } function destroy() { @unlink($this->tmp_path); return true; } } class ImagickPixel { } ?>