/** * gets the shell command to be executed * @see phMagick\Core.Action::getShellCommand() */ public function getShellCommand() { $command = new Command(); $width = $this->getWidth(); $height = $this->getHeight(); if ($width < 0) { throw new \InvalidArgumentException('With must not be negative'); } if ($height < 0) { throw new \InvalidArgumentException('Height must not be negative'); } if ($width == 0 && $height == 0) { throw new \InvalidArgumentException('width and height must be greater than 0'); } $command->binary('convert')->file($this->getSource())->param('-scale', $width . 'x' . $height . '!')->file($this->getDestination()); return $command; }
public function getShellCommand() { $command = new Command(); $transparency = $this->getTransparency(); $watermark = $this->getWatermarkImage(); $gravity = $this->getGravity(); $command->binary('composite')->param('-dissolve', $transparency)->param('-gravity', $gravity, true)->file($watermark)->file($this->getSource())->file($this->getDestination()); return $command; }
private function execute(Command $cmdCls) { $ret = null; $out = array(); $log = $this->getLogger(); $cmd = $cmdCls->toString(); if ($this->isWindows()) { $cmd = str_replace('(', '\\(', $cmd); $cmd = str_replace(')', '\\)', $cmd); } exec($cmd . ' 2>&1', $out, $ret); $log->append(array('cmd' => $cmd, 'return' => $ret, 'output' => $out)); if ($ret != 0) { $msg = 'Error #' . $ret . ' while executing "' . $cmd . '"'; if ($this->debugMode()) { $msg .= "\n Debug Log: \n" . $log; } throw new SystemException($msg); } return $ret; }
/** * gets the shell command to be executed * @see phMagick\Core.Action::getShellCommand() */ public function getShellCommand() { $command = new Command(); $command->binary('convert')->file($this->getSource()); if ($this->optimize) { $command->option('-strip'); } if (null !== $this->quality) { $command->param('-quality', $this->quality); } $command->file($this->getDestination()); return $command; }
public function getShellCommand() { $command = new Command(); $width = $this->getWidth(); if (is_null($width)) { throw new \InvalidArgumentException('please specify width'); } $height = $this->getHeight(); if (is_null($height)) { throw new \InvalidArgumentException('please specify height'); } $top = $this->getTop(); $left = $this->getLeft(); $gravity = $this->getGravity(); $command->binary('convert')->file($this->getSource())->param('-gravity', $gravity, true)->param('-crop', $width . 'x' . $height . '+' . $left . '+' . $top)->file($this->getDestination()); return $command; }