aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--languages/en.php2
-rw-r--r--lib/watermark.php93
2 files changed, 18 insertions, 77 deletions
diff --git a/languages/en.php b/languages/en.php
index f3abfc27e..036884799 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -62,7 +62,7 @@
'tidypics:settings:grp_perm_override' => "Allow group members full access to group albums",
'tidypics:settings:maxfilesize' => "Maximum image size in megabytes (MB):",
'tidypics:settings:quota' => "User/Group Quota (MB) - 0 equals no quota",
- 'tidypics:settings:watermark' => "Enter text to appear in the watermark - ImageMagick Cmdline must be selected for the image library",
+ 'tidypics:settings:watermark' => "Enter text to appear in the watermark - not for production sites yet",
'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands (with trailing slash)",
'tidypics:settings:img_river_view' => "How many entries in river for each batch of uploaded images",
'tidypics:settings:album_river_view' => "Show the album cover or a set of photos for new album",
diff --git a/lib/watermark.php b/lib/watermark.php
index 160dd48b4..13eb598a0 100644
--- a/lib/watermark.php
+++ b/lib/watermark.php
@@ -45,103 +45,44 @@ function tp_gd_watermark($image) {
$top = $image_height - $line_height - 10;
$left = round(($image_width - $line_width) / 2);
- $textcolor = imagecolorallocate($image, 50, 50, 50);
+ imagealphablending($image, true);
+ $textcolor = imagecolorallocatealpha($image, 50, 50, 50, 50);
imagestring($image, $font, $left, $top, $watermark_text, $textcolor);
}
function tp_imagick_watermark($filename) {
+
$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);
- $ext = ".png";
-
- $user_stamp_base = tp_get_watermark_filename($watermark_text, $owner);
+ $img = new Imagick($filename);
- $watermark = array();
- $image = new Imagick($filename);
- $draw = new ImagickDraw();
- $draw->setGravity(Imagick::GRAVITY_CENTER);
- # $draw->setFont($font);
- # $draw->setFontSize($font_size);
- $textColor = new ImagickPixel("black");
- $draw->setFillColor($textColor);
-
- $im = new imagick();
- $properties = $im->queryFontMetrics($draw, $watermark_text);
- $watermark['w'] = intval($properties["textWidth"] + 5);
- $watermark['h'] = intval($properties["textHeight"] + 5);
- $im->newImage($watermark['w'],$watermark['h'],new ImagickPixel("transparent"));
- $im->setImageFormat("jpg");
- $im->annotateImage($draw, 0, 0, 0, $watermark_text);
- $watermark = $im->clone();
- $watermark->setImageBackgroundColor($textColor);
- $watermark->shadowImage(80, 2, 2, 2);
- $watermark->compositeImage($im, Imagick::COMPOSITE_OVER, 0, 0);
- $image->compositeImage($watermark, Imagick::COMPOSITE_OVER, 0, 0);
-
- if ($image->writeImage($filename) != true) {
- $image->destroy();
- return false;
- }
-
- $image->destroy();
-/*
- if ( !file_exists( $user_stamp_base . $ext )) { //create the watermark if it doesn't exist
+ $img->readImage($image);
- $commands = array();
- $commands[] = $im_path . 'convert -size 300x50 xc:grey30 -pointsize 20 -gravity center -draw "fill grey70 text 0,0 \''. $watermark_text . '\'" "'. $user_stamp_base . '_fgnd' . $ext . '"';
- $commands[] = $im_path . 'convert -size 300x50 xc:black -pointsize 20 -gravity center -draw "fill white text 1,1 \''. $watermark_text . '\' text 0,0 \''. $watermark_text . '\' fill black text -1,-1 \''. $watermark_text . '\'" +matte ' . $user_stamp_base . '_mask' . $ext;
- $commands[] = $im_path . 'composite -compose CopyOpacity "' . $user_stamp_base . "_mask" . $ext . '" "' . $user_stamp_base . '_fgnd' . $ext . '" "' . $user_stamp_base . $ext . '"';
- $commands[] = $im_path . 'mogrify -trim +repage "' . $user_stamp_base . $ext . '"';
- $commands[] = 'rm "' . $user_stamp_base . '_mask' . $ext . '"';
- $commands[] = 'rm "' . $user_stamp_base . '_fgnd' . $ext . '"';
-
- foreach( $commands as $command ) {
- exec( $command );
- }
+ $draw = new ImagickDraw();
- }
-*/
-/*
- try {
- $img = new Imagick($filename);
- } catch (ImagickException $e) {
- return false;
- }
-
- try {
- $mask = new Imagick($user_stamp_base . $ext);
- } catch (ImagickException $e) {
- return false;
- }
-
- $image_width = $img->getImageWidth();
- $image_height = $img->getImageHeight();
- $mask_width = $mask->getImageWidth();
- $mask_height = $mask->getImageHeight();
-
- // matching -gravity south -geometry +0+10
- $top = $image_height - $mask_height - 10;
- $left = round(($image_width - $mask_width) / 2);
-
- $img->compositeImage($mask, Imagick::COMPOSITE_DEFAULT, $left, $top);
-
- $mask->destroy();
-
+ //$draw->setFont("");
+
+ $draw->setFontSize(28);
+
+ $draw->setFillOpacity(0.5);
+
+ $draw->setGravity(Imagick::GRAVITY_SOUTH);
+
+ $img->annotateImage($draw, 0, 0, 0, $watermark_text);
+
if ($img->writeImage($filename) != true) {
$img->destroy();
return false;
}
$img->destroy();
-*/
+
return true;
}