Example #1
0
 /**
  * Draws an image with the submited string, usefull for water marks
  *
  * @param $text String - the text to draw an image from
  * @param $format phMagickTextObject - the text configuration
  */
 function fromString(phmagick $p, $text = '', phMagickTextObject $format = null)
 {
     if (is_null($format)) {
         $format = new phMagickTextObject();
     }
     $cmd = $p->getBinary('convert');
     if ($format->background !== false) {
         $cmd .= ' -background "' . $format->background . '"';
     }
     if ($format->color !== false) {
         $cmd .= ' -fill "' . $format->color . '"';
     }
     if ($format->font !== false) {
         $cmd .= ' -font ' . $format->font;
     }
     if ($format->fontSize !== false) {
         $cmd .= ' -pointsize ' . $format->fontSize;
     }
     if ($format->pText != '' && ($text = '')) {
         $text = $format->pText;
     }
     $cmd .= ' label:"' . $text . '"';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #2
0
 function convert(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;
 }
Example #3
0
 /**
  * Flips the image horizonaly
  * @return unknown_type
  */
 function flipHorizontal(phmagick $p)
 {
     $cmd = $p->getBinary('convert');
     $cmd .= ' -flop ';
     $cmd .= ' "' . $p->getSource() . '"';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #4
0
 /**
  *
  * @param $width Integer
  * @param $height Integer
  * @param $top Integer - The Y coordinate for the left corner of the crop rectangule
  * @param $left Integer - The X coordinate for the left corner of the crop rectangule
  * @param $gravity phMagickGravity - The initial placement of the crop rectangule
  * @return unknown_type
  */
 function crop(phmagick $p, $width, $height, $top = 0, $left = 0, $gravity = 'center')
 {
     $cmd = $p->getBinary('convert');
     $cmd .= ' ' . $p->getSource();
     if ($gravity != '' || $gravity != phMagickGravity::None) {
         $cmd .= ' -gravity ' . $gravity;
     }
     $cmd .= ' -crop ' . (int) $width . 'x' . (int) $height;
     $cmd .= '+' . $left . '+' . $top;
     $cmd .= ' ' . $p->getDestination();
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #5
0
 function resize(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;
 }
Example #6
0
 /**
  * Attempts to create an image(s) from a File (PDF & Avi are supported on most systems)
  * it grabs the first frame / page from the source file
  * @param $file  String - the path to the file
  * @param $ext   String - the extention of the generated image
  */
 function acquireFrame(phmagick $p, $file, $frames = 0)
 {
     // $cmd = 'echo "" | '; //just a workarround for videos,
     //                    imagemagick first converts all frames then deletes all but the first
     $cmd = $p->getBinary('convert');
     $cmd .= ' "' . $file . '"[' . $frames . ']';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #7
0
 function edges(phmagick $p, $amount = 10)
 {
     $cmd = $p->getBinary('convert');
     $cmd .= ' -adaptive-sharpen 2x' . $amount;
     $cmd .= ' -background "none" "' . $p->getSource() . '"';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #8
0
 function autoLevels(phmagick $p)
 {
     $cmd = $p->getBinary('convert');
     $cmd .= ' -normalize ';
     $cmd .= ' -background "none" "' . $p->getSource() . '"';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #9
0
 function border(phmagick $p, $borderColor = "#000", $borderSize = "1")
 {
     $cmd = $p->getBinary('convert');
     $cmd .= ' "' . $p->getSource() . '"';
     $cmd .= ' -bordercolor "' . $borderColor . '"  -border ' . $borderSize;
     $cmd .= ' "' . $p->getDestination() . '"';
     $ret = $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }