1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10: class Horde_Image_Effect_Im_TextWatermark extends Horde_Image_Effect
11: {
12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: protected $_params = array('halign' => 'right',
25: 'valign' => 'bottom',
26: 'font' => 'courier',
27: 'fontsize' => 'small');
28:
29: 30: 31: 32:
33: public function apply()
34: {
35:
36: switch ($this->_params['valign']) {
37: case 'bottom':
38: $v = 'south';
39: break;
40: case 'center':
41: $v = 'center';
42: break;
43: default:
44: $v = 'north';
45: }
46:
47: switch ($this->_params['halign']) {
48: case 'right':
49: $h = 'east';
50: break;
51: case 'center':
52: $h = 'center';
53: break;
54: default:
55: $h = 'west';
56:
57: }
58: if (($v == 'center' && $h != 'center') ||
59: ($v == 'center' && $h == 'center')) {
60: $gravity = $h;
61: } elseif ($h == 'center' && $v != 'center') {
62: $gravity = $v;
63: } else {
64: $gravity = $v . $h;
65: }
66:
67: $point = $this->_image->getFontSize($this->_params['fontsize']);
68: $this->_image->raw();
69: $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 "' . $this->_params['text'] . '"');
70: $this->_image->raw();
71: }
72:
73: }
74: