Example #1
0
 function glow(phmagick $p, $color = '#827f00', $offset = 10, $transparency = 60)
 {
     $p->requirePlugin('info');
     list($w, $h) = $p->getInfo($p->getSource());
     $cmd = $p->getBinary('convert');
     $cmd .= ' "' . $p->getSource() . '" ';
     $cmd .= '( +clone  -background "' . $color . '"  -shadow ' . $transparency . 'x' . $offset . '-' . $offset / 4 . '+' . $offset / 4 . ' ) +swap -background none   -layers merge  +repage  ';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #2
0
 /**
  *
  *  Brightens an image, defualt: 50%
  *
  * @param $imageFile String - Physical path of the umage file
  * @param $newFile String - Physical path of the generated image
  * @param $alphaValue Integer - 100: white , 0: original color (no change)
  * @return boolean - True: success
  */
 function brighten(phmagick $p, $alphaValue = 50)
 {
     $percent = 100 - (int) $alphaValue;
     //get original file dimentions
     list($width, $height) = $p->getInfo();
     $cmd = $p->getBinary('composite');
     $cmd .= ' -blend  ' . $percent . ' ';
     $cmd .= '"' . $p->getSource() . '"';
     $cmd .= ' -size ' . $width . 'x' . $height . ' xc:white ';
     $cmd .= '-matte "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
Example #3
0
 /**
  * tries to resize an image to the exact size wile mantaining aspect ratio,
  * the image will be croped to fit the measures
  * @param $width
  * @param $height
  */
 function resizeExactly(phmagick $p, $width, $height)
 {
     //requires Crop plugin
     //requires dimensions plugin
     $p->requirePlugin('crop');
     $p->requirePlugin('info');
     list($w, $h) = $p->getInfo($p->getSource());
     if ($w > $h) {
         $h = $height;
         $w = 0;
     } else {
         $h = 0;
         $w = $width;
     }
     $p->resize($w, $h)->crop($width, $height);
 }