XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
crop.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 */
40  function crop(phmagick $p, $width, $height, $top = 0, $left = 0, $gravity = 'center'){
41  $cmd = $p->getBinary('convert');
42  $cmd .= ' ' . $p->getSource() ;
43 
44  if (($gravity != '')|| ($gravity != phMagickGravity::None) ) $cmd .= ' -gravity ' . $gravity ;
45 
46  $cmd .= ' -crop ' . (int)$width . 'x'.(int)$height ;
47  $cmd .= '+' . $left.'+'.$top;
48  $cmd .= ' ' . $p->getDestination() ;
49 
50  $p->execute($cmd);
51  $p->setSource($p->getDestination());
52  $p->setHistory($p->getDestination());
53  return $p ;
54  }
55 }
56 ?>