31 protected function crop($width, $height, $x = 0, $y = 0)
33 if (!$this->
bypassTest($width, $height, $x, $y)) {
34 $this->image->setImageGravity(\Imagick::GRAVITY_NORTHWEST);
35 $this->image->cropImage($width, $height, $x, $y);
36 $this->image->extentImage($width, $height, 0, 0);
37 $this->image->setImagePage(0, 0, 0, 0);
38 $this->size = array($width, $height);
47 protected function resize($width, $height)
51 if (!$this->
bypassTest($newSize[0], $newSize[1])) {
54 $this->image->setImageGravity(\Imagick::GRAVITY_CENTER);
55 $this->image->resizeImage($newSize[0], $newSize[1], $filter, 1);
56 $this->image->setImageExtent($newSize[0], $newSize[1]);
57 $this->size = $newSize;
66 protected function thumb($width, $height)
68 list($width, $height) = $this->
dimensions($width, $height);
75 if ($newSize[1] > $height) {
77 $xOffset = -1 * round(($width - $newSize[0]) / 2);
79 $yOffset = -1 * round(($height - $newSize[1]) / 2);
83 $this->image->resizeImage($newSize[0], $newSize[1], $filter, 1,
true);
84 $this->image->extentImage($width, $height, $xOffset, $yOffset);
85 $this->size = array($newSize[0], $newSize[1]);
94 protected function thumbfill($width, $height, $centerX = 50, $centerY = 50)
96 list($width, $height) = $this->
dimensions($width, $height);
98 if (!$this->
bypassTest($width, $height, $centerX - 50, $centerY - 50)) {
103 if ($newSize[1] < $height) {
105 $xOffset = -1 * round(($width - $newSize[0]) * $centerX);
109 $yOffset = -1 * round(($height - $newSize[1]) * $centerY);
113 $this->image->resizeImage($newSize[0], $newSize[1], $filter, 1,
true);
114 $this->image->extentImage($width, $height, $xOffset, $yOffset);
115 $this->size = array($width, $height);
127 $this->image = new \Imagick(realpath($this->input));
128 $this->image->transformImageColorspace(\Imagick::COLORSPACE_SRGB);
140 $result = $this->image->writeImage($this->output);
142 $this->image->clear();
145 throw new \Depage\Graphics\Exceptions\Exception(
'Could not save output image.');
156 if ($this->background[0] ===
'#') {
157 $this->image->setImageBackgroundColor($this->background);
158 } elseif ($this->background ==
'checkerboard') {
160 if ($this->outputFormat ==
'jpg') {
161 $this->image->setImageBackgroundColor(
'#fff');
163 $this->image->setImageBackgroundColor(
'transparent');
177 if ($width <= 160 && $height <= 160) {
178 return \Imagick::FILTER_TRIANGLE;
180 return \Imagick::FILTER_LANCZOS;
190 $this->image = new \Imagick(realpath($this->input));
193 $this->image->getImageWidth(),
194 $this->image->getImageHeight()
216 if ($this->otherRender && file_exists($this->output)) {
219 && $this->inputFormat == $this->outputFormat
225 if ($this->optimize) {
230 parent::renderFinished();
processQueue()
Process action queue.
bypassTest($width, $height, $x=0, $y=0)
Tests if action would change current image.
dimensions($width, $height)
Scales image dimensions.
optimizeImage($filename)
Opimizes final image through one of the optimization programs.
bypass()
Runs bypass (copies file)
thumbfill($width, $height, $centerX=50, $centerY=50)
thumbfill
setBackground()
Generates background command.
getResizeFilter($width, $height)
Gets the resize filter depending on target size.
getImageSize()
Determine size of input image.
render($input, $output=null)
Main method for image handling.
resize($width, $height)
resize
crop($width, $height, $x=0, $y=0)
crop
thumb($width, $height)
thumb