/**
  * Draws an ellipse on the handle
  *
  * @param ImageMagick-object $handle The handle on which the ellipse is drawn
  * @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info
  */
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawEllipse $ellipseObject)
 {
     $draw = new ImagickDraw();
     $strokeColor = (string) $ellipseObject->getStrokeColor();
     $strokeAlpha = $ellipseObject->getStrokeAlpha() * 0.01;
     $draw->setStrokeColor($strokeColor);
     $draw->setStrokeOpacity($strokeAlpha);
     $draw->setStrokeWidth($ellipseObject->getStrokeWidth());
     $strokeDashArray = $ellipseObject->getStrokeDashPattern();
     if (count($strokeDashArray) > 0) {
         $draw->setStrokeDashArray($strokeDashArray);
     }
     $draw->setStrokeDashOffset($ellipseObject->getStrokeDashOffset());
     if ($ellipseObject->filled()) {
         $fillColor = (string) $ellipseObject->getFillColor();
         $draw->setFillColor($fillColor);
         $draw->setFillOpacity($ellipseObject->getFillAlpha() * 0.01);
     } else {
         $draw->setFillOpacity(0);
     }
     $width = $ellipseObject->getWidth();
     $height = $ellipseObject->getHeight();
     $x = $ellipseObject->getLocation()->getX();
     $y = $ellipseObject->getLocation()->getY();
     $draw->ellipse($x, $y, $width / 2, $height / 2, 0, 360);
     $adapter->getHandle()->drawImage($draw);
 }
Exemple #2
0
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_Rotate $rotate)
 {
     $handle = $adapter->getHandle();
     $angle = $rotate->getAngle();
     $background = new ImagickPixel($rotate->getBackgroundColor(true));
     $handle->rotateImage($background, $angle);
     return $handle;
 }
Exemple #3
0
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_Crop $crop)
 {
     $handle = $adapter->getHandle();
     $x = $crop->getX();
     $y = $crop->getY();
     $width = $crop->getWidth();
     $height = $crop->getHeight();
     $handle->cropImage($width, $height, $x, $y);
 }
Exemple #4
0
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_Mirror $rotate)
 {
     $handle = $adapter->getHandle();
     if ($rotate->flop()) {
         $handle->flopImage();
     }
     if ($rotate->flip()) {
         $handle->flipImage();
     }
 }
Exemple #5
0
 /**
  * Draw a line on the image, returns the GD-handle
  *
  * @param  Zend_Image_Adapter_ImageMagick image resource    $handle Image to work on
  * @param  Zend_Image_Action_DrawLine   $lineObject The object containing all settings needed for drawing a line.
  * @return void
  */
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawLine $lineObject)
 {
     $handle = $adapter->getHandle();
     $draw = new ImagickDraw();
     $draw->setStrokeWidth($lineObject->getStrokeWidth());
     $color = $lineObject->getStrokeColor();
     $draw->setStrokeColor((string) $color);
     $draw->setStrokeOpacity($lineObject->getStrokeAlpha());
     $draw->line($lineObject->getPointStart()->getX(), $lineObject->getPointStart()->getY(), $lineObject->getPointEnd()->getX(), $lineObject->getPointEnd()->getY());
     $handle->drawImage($draw);
 }
Exemple #6
0
 /**
  * Draws some text on the handle
  *
  * @param Zend_Image_Adapter_ImageMagick $adapter Adapter
  * @param Zend_Image_Action_DrawText $textObject The object that with all info
  */
 public function perform($adapter, Zend_Image_Action_DrawText $textObject)
 {
     // As of ZF2.0 / PHP5.3, this can be made static.
     $handle = $adapter->getHandle();
     $color = new ImagickPixel('#000000');
     // . $textObject->getColor());
     $draw = new ImagickDraw();
     $draw->annotation($textObject->getOffsetX(), $textObject->getOffsetY(), $textObject->getText());
     $handle->drawImage($draw);
     return $handle;
 }
Exemple #7
0
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_Resize $resize)
 {
     $handle = $adapter->getHandle();
     $newY = $resize->getYAmountCalculated();
     $newX = $resize->getXAmountCalculated();
     //if a dimension is 0, resize is proportionate to other dimension
     //if proportions are constrained and both dimensions are specified,
     //ImageMagick uses the smallest to constrain
     //
     //Note the fit parameter only works if the image is being made SMALLER
     //@TODO: implement constraints manually for images being made larger
     $fit = false;
     if ($resize->hasConstrainedProportions() && $newX > 0 && $newY > 0) {
         $fit = true;
     }
     $handle->resizeImage($newX, $newY, $resize->getFilter(), 1, $fit);
 }