/usr/share/php/Horde/Image/Effect/Im/TextWatermark.php is in php-horde-image 2.5.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | <?php
/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
* @package Image
*/
/**
* Image effect for watermarking images with text.
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @category Horde
* @copyright 2007-2017 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
* @package Image
*/
class Horde_Image_Effect_Im_TextWatermark extends Horde_Image_Effect
{
/**
* Valid parameters for watermark effects:
* - text: [REQUIRED] (string) The text of the watermark.
* - halign: (string) The horizontal placement
* - valign: (string) The vertical placement
* - font: (string) The font name or family to use
* - fontsize: (string) The size of the font to use (small, medium,
* large, giant)
*
* @var array
*/
protected $_params = array(
'halign' => 'right',
'valign' => 'bottom',
'font' => 'courier',
'fontsize' => 'small'
);
/**
* Applies the effect.
*/
public function apply()
{
/* Determine placement on image */
switch ($this->_params['valign']) {
case 'bottom':
$v = 'south';
break;
case 'center':
$v = 'center';
break;
default:
$v = 'north';
}
switch ($this->_params['halign']) {
case 'right':
$h = 'east';
break;
case 'center':
$h = 'center';
break;
default:
$h = 'west';
}
if (($v == 'center' && $h != 'center') ||
($v == 'center' && $h == 'center')) {
$gravity = $h;
} elseif ($h == 'center' && $v != 'center') {
$gravity = $v;
} else {
$gravity = $v . $h;
}
/* Determine font point size */
$point = Horde_Image::getFontSize($this->_params['fontsize']);
$this->_image->raw();
$this->_image->addPostSrcOperation(
' -font ' . $this->_params['font'] . ' -pointsize ' . $point
. ' \( +clone -resize 1x1 -fx 1-intensity -threshold 50% -scale 32x32 -write mpr:color +delete \) -tile mpr:color -gravity '
. $gravity . ' -annotate +20+10 "' . escapeshellarg($this->_params['text']) . '"'
);
$this->_image->raw();
}
}
|