aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-07-17 00:37:28 +0000
committerCash Costello <cash.costello@gmail.com>2009-07-17 00:37:28 +0000
commit19714b046eb9c385a671d1c8f1e8890d694400b7 (patch)
tree7fd646f8d6e0815bb94e1e596a83223a09760c93 /lib
parent6896c4082a9ab3636380e8b1407635274dabab8e (diff)
downloadelgg-19714b046eb9c385a671d1c8f1e8890d694400b7.tar.gz
elgg-19714b046eb9c385a671d1c8f1e8890d694400b7.tar.bz2
continue to build watermarking code
Diffstat (limited to 'lib')
-rw-r--r--lib/resize.php10
-rw-r--r--lib/watermark.php26
2 files changed, 33 insertions, 3 deletions
diff --git a/lib/resize.php b/lib/resize.php
index 894a68fff..803cb8fa7 100644
--- a/lib/resize.php
+++ b/lib/resize.php
@@ -34,6 +34,7 @@
$thumbname = $thumb->getFilenameOnFilestore();
$rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(),
$thumbname,
+ false,
$image_sizes['thumb_image_width'],
$image_sizes['thumb_image_height'],
true);
@@ -47,6 +48,7 @@
$thumbname = $thumb->getFilenameOnFilestore();
$rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(),
$thumbname,
+ false,
$image_sizes['small_image_width'],
$image_sizes['small_image_height'],
true);
@@ -60,6 +62,7 @@
$thumbname = $thumb->getFilenameOnFilestore();
$rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(),
$thumbname,
+ true,
$image_sizes['large_image_width'],
$image_sizes['large_image_height'],
false);
@@ -67,7 +70,6 @@
return false;
$file->largethumb = $prefix."largethumb".$filestorename;
- tp_gd_watermark($thumbname);
unset($thumb);
@@ -80,12 +82,13 @@
*
* @param string $input_name The name of the file on the disk
* @param string $output_name The name of the file to be written
+ * @param bool - watermark this image?
* @param int $maxwidth The maximum width of the resized image
* @param int $maxheight The maximum height of the resized image
* @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped.
* @return bool true on success or false on failure
*/
- function tp_gd_resize($input_name, $output_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) {
+ function tp_gd_resize($input_name, $output_name, $watermark, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) {
// Get the size information from the image
$imgsizearray = getimagesize($input_name);
@@ -176,6 +179,9 @@
if (!rtn_code)
return $rtn_code;
+ if ($watermark)
+ tp_gd_watermark($newimage);
+
switch ($imgsizearray['mime']) {
case 'image/jpeg':
case 'image/pjpeg':
diff --git a/lib/watermark.php b/lib/watermark.php
index b80e1b9e9..2263bdd8f 100644
--- a/lib/watermark.php
+++ b/lib/watermark.php
@@ -22,7 +22,31 @@ function tp_get_watermark_filename($text, $owner) {
return $filename;
}
-function tp_gd_watermark($filename) {
+function tp_gd_watermark($image) {
+ $watermark_text = get_plugin_setting('watermark_text', 'tidypics');
+ if (!$watermark_text)
+ return;
+
+
+ $owner = get_loggedin_user();
+
+ $watermark_text = tp_process_watermark_text($watermark_text, $owner);
+
+
+
+ $font = 5;
+ $line_width = strlen($watermark_text) * imagefontwidth($font);
+ $line_height = imagefontheight($font);
+
+ $image_width = 600;
+ $image_height = 450;
+
+ // matching -gravity south -geometry +0+10
+ $top = $image_height - $line_height - 10;
+ $left = round(($image_width - $line_width) / 2);
+
+ $textcolor = imagecolorallocate($image, 0, 0, 255);
+ imagestring($image, $font, $left, $top, $watermark_text, $textcolor);
}
function tp_imagick_watermark($filename) {