XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
compose.php
Go to the documentation of this file.
1 <?php
2 /*
3  +--------------------------------------------------------------------------------------------+
4  | DISCLAIMER - LEGAL NOTICE - |
5  +--------------------------------------------------------------------------------------------+
6  | |
7  | This program is free for non comercial use, see the license terms available at |
8  | http://www.francodacosta.com/licencing/ for more information |
9  | |
10  | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
11  | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12  | |
13  | USE IT AT YOUR OWN RISK |
14  | |
15  | |
16  +--------------------------------------------------------------------------------------------+
17 
18 */
38  function watermark(phmagick $p, $watermarkImage, $gravity = 'center', $transparency = 50){
39  //composite -gravity SouthEast watermark.png original-image.png output-image.png
40  $cmd = $p->getBinary('composite');
41  $cmd .= ' -dissolve ' . $transparency ;
42  $cmd .= ' -gravity ' . $gravity ;
43  $cmd .= ' ' . $watermarkImage ;
44  $cmd .= ' "' . $p->getSource() .'"' ;
45  $cmd .= ' "' . $p->getDestination() .'"' ;
46 
47  $p->execute($cmd);
48  $p->setSource($p->getDestination());
49  $p->setHistory($p->getDestination());
50  return $p ;
51  }
52 
59  function tile(phmagick $p, Array $paths = null, $tileWidth = '', $tileHeight=1){
60  if( is_null($paths) ) {
62  }
63  $cmd = $p->getBinary('montage');
64  $cmd .= ' -geometry x+0+0 -tile '.$tileWidth.'x'.$tileHeight.' ';
65  $cmd .= implode(' ', $paths);
66  $cmd .= ' "' . $p->getDestination() .'"' ;
67 
68  $p->execute($cmd);
69  $p->setSource($p->getDestination());
70  $p->setHistory($p->getDestination());
71  return $p ;
72  }
73 
80  function acquireFrame(phmagick $p, $file, $frames=0){
81  // $cmd = 'echo "" | '; //just a workarround for videos,
82  // imagemagick first converts all frames then deletes all but the first
83  $cmd = $p->getBinary('convert');
84  $cmd .= ' "' . $file .'"['.$frames.']' ;
85  $cmd .= ' "' . $p->getDestination().'"' ;
86 
87  $p->execute($cmd);
88  $p->setSource($p->getDestination());
89  $p->setHistory($p->getDestination());
90  return $p ;
91  }
92 }
93 ?>