示例#1
0
 function getMime(JO_Phpthumb_Factory_Imagick_Phmagick $p, $file = '')
 {
     if ($file == '') {
         $file = $p->getSource();
     }
     $info = getimagesize($file);
     return $info["mime"];
 }
示例#2
0
 function convert(JO_Phpthumb_Factory_Imagick_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;
 }
示例#3
0
 /**
  * tries to resize an image to the exact size wile mantaining aspect ratio,
  * the image will be padded with background color to fit the measures
  * @param $width
  * @param $height
  * @param $background
  */
 function resizeExactlyNoCrop(JO_Phpthumb_Factory_Imagick_Phmagick $p, $width, $height, $background = '#FFFFFF')
 {
     $cmd = $p->getBinary('montage');
     $cmd .= ' -background ' . '"' . $background . '"';
     $cmd .= ' -geometry ' . $width . 'x' . $height;
     $cmd .= ' "' . $p->getSource() . '" "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
示例#4
0
 /**
  * Add's an watermark to an image
  *
  * @param $watermarkImage String - Image path
  * @param $gravity phMagickGravity - The placement of the watermark
  * @param $transparency Integer - 1 to 100 the tranparency of the watermark (100 = opaque)
  */
 function watermark(JO_Phpthumb_Factory_Imagick_Phmagick $p, $watermarkImage, $gravity = 'center', $transparency = 50)
 {
     //composite -gravity SouthEast watermark.png original-image.png output-image.png
     $cmd = $p->getBinary('composite');
     $cmd .= ' -dissolve ' . $transparency;
     $cmd .= ' -gravity ' . $gravity;
     $cmd .= ' ' . $watermarkImage;
     $cmd .= ' "' . $p->getSource() . '"';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
示例#5
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(JO_Phpthumb_Factory_Imagick_Phmagick $p, $width, $height, $top = 0, $left = 0, $gravity = 'center')
 {
     $cmd = $p->getBinary('convert');
     $cmd .= ' ' . $p->getSource();
     if ($gravity != '' || $gravity != JO_Phpthumb_Factory_Imagick_Phmagick_Gravity::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;
 }
示例#6
0
 /**
  * Flips the image horizonaly and verticaly
  * @return unknown_type
  */
 function reflection(JO_Phpthumb_Factory_Imagick_Phmagick $p, $size = 60, $transparency = 50)
 {
     $p->requirePlugin('info');
     $source = $p->getSource();
     //invert image
     $this->flipVertical($p);
     //crop it to $size%
     list($w, $h) = $p->getInfo($p->getDestination());
     $p->crop($w, $h * ($size / 100), 0, 0, JO_Phpthumb_Factory_Imagick_Phmagick_Gravity::None);
     //make a image fade to transparent
     $cmd = $p->getBinary('convert');
     $cmd .= ' "' . $p->getSource() . '"';
     $cmd .= ' ( -size ' . $w . 'x' . $h * ($size / 100) . ' gradient: ) ';
     $cmd .= ' +matte -compose copy_opacity -composite ';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     //apply desired transparency, by creating a transparent image and merge the mirros image on to it with the desired transparency
     $file = dirname($p->getDestination()) . '/' . uniqid() . '.png';
     $cmd = $p->getBinary('convert');
     $cmd .= '  -size ' . $w . 'x' . $h * ($size / 100) . ' xc:none  ';
     $cmd .= ' "' . $file . '"';
     $p->execute($cmd);
     $cmd = $p->getBinary('composite');
     $cmd .= ' -dissolve ' . $transparency;
     $cmd .= ' "' . $p->getDestination() . '"';
     $cmd .= ' ' . $file;
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     unlink($file);
     //append the source and the relfex
     $cmd = $p->getBinary('convert');
     $cmd .= ' "' . $source . '"';
     $cmd .= ' "' . $p->getDestination() . '"';
     $cmd .= ' -append ';
     $cmd .= ' "' . $p->getDestination() . '"';
     $p->execute($cmd);
     $p->setSource($p->getDestination());
     $p->setHistory($p->getDestination());
     return $p;
 }
示例#7
0
 function autoLevels(JO_Phpthumb_Factory_Imagick_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;
 }
示例#8
0
 function border(JO_Phpthumb_Factory_Imagick_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;
 }
示例#9
0
 function edges(JO_Phpthumb_Factory_Imagick_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;
 }