Exemplo n.º 1
0
 function getMime(JO_Phpthumb_Factory_Imagick_Phmagick $p, $file = '')
 {
     if ($file == '') {
         $file = $p->getSource();
     }
     $info = getimagesize($file);
     return $info["mime"];
 }
Exemplo n.º 2
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(JO_Phpthumb_Factory_Imagick_Phmagick $p, $text = '', JO_Phpthumb_Factory_Imagick_Phmagick_Textobject $format = null)
 {
     if (is_null($format)) {
         $format = new JO_Phpthumb_Factory_Imagick_Phmagick_Textobject();
     }
     $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;
 }
Exemplo n.º 3
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(JO_Phpthumb_Factory_Imagick_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;
 }
Exemplo n.º 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(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;
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
 /**
  * Creates a thumbnail of an image, if it doesn't exits
  *
  *
  * @param String $imageUrl - The image Url
  * @param Mixed $width - String / Integer
  * @param Mixed $height - String / Integer
  * @param boolean: False: resizes the image to the exact porportions (aspect ratio not preserved). True: preserves aspect ratio, only resises if image is bigger than specified measures
  *
  * @return String - the thumbnail URL
  */
 function onTheFly(JO_Phpthumb_Factory_Imagick_Phmagick $p, $imageUrl, $width, $height, $exactDimentions = false, $webPath = '', $physicalPath = '')
 {
     //convert web path to physical
     $basePath = str_replace($webPath, $physicalPath, dirname($imageUrl));
     $sourceFile = $basePath . '/' . basename($imageUrl);
     //naming the new thumbnail
     $thumbnailFile = $basePath . '/' . $width . '_' . $height . '_' . basename($imageUrl);
     $p->setSource($sourceFile);
     $p->setDestination($thumbnailFile);
     if (!file_exists($thumbnailFile)) {
         $p->resize($p, $width, $height, $exactDimentions);
     }
     if (!file_exists($thumbnailFile)) {
         //if there was an error, just use original file
         $thumbnailFile = $sourceFile;
     }
     //returning the thumbnail url
     return str_replace($physicalPath, $webPath, $thumbnailFile);
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 9
0
 function save(JO_Phpthumb_Factory_Imagick_Phmagick $p)
 {
     return $p->convert($p);
 }
Exemplo n.º 10
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;
 }