31 protected function crop($width, $height, $x = 0, $y = 0)
33 if (!$this->
bypassTest($width, $height, $x, $y)) {
35 $x = ($x < 0) ? $x :
'+' . $x;
36 $y = ($y < 0) ? $y :
'+' . $y;
38 $xExtent = ($x > 0) ?
"+0" : $x;
39 $yExtent = ($y > 0) ?
"+0" : $y;
40 $this->command .=
" -gravity NorthWest -crop {$width}x{$height}{$x}{$y}! -gravity NorthWest -extent {$width}x{$height}{$xExtent}{$yExtent}";
41 $this->size = array($width, $height);
53 if (is_callable(
'getimagesize')) {
54 $imageSize = getimagesize($this->input);
58 exec(
"{$this->executable} identify -ping -format \"%wx%h\" " . escapeshellarg($this->input) . $pageNumber .
' 2>&1', $commandOutput, $returnStatus);
59 if ($returnStatus === 0) {
60 $imageSize = explode(
'x', $commandOutput[0]);
64 throw new \Depage\Graphics\Exceptions\Exception(implode(
"\n", $commandOutput));
86 $this->command = $this->executable .
" convert " . escapeshellarg($this->input) .
"{$pageNumber} -background none";
89 if ($this->otherRender && file_exists($this->output)) {
93 && $this->inputFormat == $this->outputFormat
100 if ($this->background ===
'checkerboard') {
101 $tempFile = tempnam(sys_get_temp_dir(),
'depage-graphics-');
102 $this->command .=
" miff:{$tempFile}";
106 $canvasSize = $this->size[0] .
"x" . $this->size[1];
108 $this->command = $this->executable .
" convert";
109 $this->command .=
" -page {$canvasSize} -size {$canvasSize} pattern:checkerboard";
110 $this->command .=
" -page {$canvasSize} miff:{$tempFile} -colorspace rgb -flatten {$quality}{$optimize} +page {$this->outputFormat}:" . escapeshellarg($this->output);
116 $this->command .=
"{$background} -colorspace rgb {$quality}{$optimize} +page {$this->outputFormat}:" . escapeshellarg($this->output);
120 if ($this->optimize) {
126 parent::renderFinished();
136 if ($this->background[0] ===
'#') {
137 $background =
" -flatten -background {$this->background}";
138 } elseif ($this->outputFormat ==
'jpg') {
$background
Image background string.
$quality
Image quality string.
processQueue()
Process action queue.
bypassTest($width, $height, $x=0, $y=0)
Tests if action would change current image.
render($input, $output=null)
Main method for image handling.
optimizeImage($filename)
Opimizes final image through one of the optimization programs.
bypass()
Runs bypass (copies file)
$optimize
Optimize output images.
GraphicsMagick interface.
getBackground()
Generates background command.
getImageSize()
Determine size of input image.
render($input, $output=null)
Main method for image handling.
crop($width, $height, $x=0, $y=0)
Crop action.
getQuality()
Generates quality command.
getPageNumber()
getPageNumber
getOptimize()
Generates optimization parameters.
execCommand()
Executes ImageMagick command.