function convert(JO_Phpthumb_Factory_Imagick_Phmagick $p) { $cmd = $p->getBinary('convert'); $cmd .= ' -quality ' . $p->getImageQuality(); $cmd .= ' "' . $p->getSource() . '" "' . $p->getDestination() . '"'; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p; }
function resize(JO_Phpthumb_Factory_Imagick_Phmagick $p, $width, $height = 0, $exactDimentions = false) { $modifier = $exactDimentions ? '!' : '>'; //if $width or $height == 0 then we want to resize to fit one measure //if any of them is sent as 0 resize will fail because we are trying to resize to 0 px $width = $width == 0 ? '' : $width; $height = $height == 0 ? '' : $height; $cmd = $p->getBinary('convert'); $cmd .= ' -scale "' . $width . 'x' . $height . $modifier; $cmd .= '" -quality ' . $p->getImageQuality(); $cmd .= ' -strip '; $cmd .= ' "' . $p->getSource() . '" "' . $p->getDestination() . '"'; $p->execute($cmd); $p->setSource($p->getDestination()); $p->setHistory($p->getDestination()); return $p; }