aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Froese <greg.froese@gmail.com>2009-05-12 13:52:21 +0000
committerGreg Froese <greg.froese@gmail.com>2009-05-12 13:52:21 +0000
commit36dbbe5be6781b3816283a35054067c99bb5cc10 (patch)
tree134e875f88f0b51067fd7dc3efd603eaf781c149
parent7e944576f4bce2fb95718d0a233af438a7bf9cd8 (diff)
downloadelgg-36dbbe5be6781b3816283a35054067c99bb5cc10.tar.gz
elgg-36dbbe5be6781b3816283a35054067c99bb5cc10.tar.bz2
added watermark option and re-enabled the code for watermarks if one is set in settings
-rw-r--r--actions/upload.php50
-rw-r--r--languages/en.php1
-rw-r--r--views/default/settings/tidypics/edit.php8
3 files changed, 32 insertions, 27 deletions
diff --git a/actions/upload.php b/actions/upload.php
index 3049d027d..797a4dfce 100644
--- a/actions/upload.php
+++ b/actions/upload.php
@@ -156,41 +156,37 @@
$thumb->setFilename($prefix."largethumb".$filestorename);
$file->largethumb = $prefix."largethumb".$filestorename;
}
-
- }
-
-/*
- $watermark = true; //gfroese - this should come from the plugin settings
- $watermark_text = $username . " - shutterpeg.com";
- if( $watermark ) { //get this value from the plugin settings
- if( $thumblarge ) {
- $ext = ".png";
- $user_stamp_base = dirname(__FILE__) . "/" . $username . "_stamp";
- if( !file_exists( $user_stamp_base . $ext )) { //create the watermark if it doesn't exist
+
+ $watermark_text = get_plugin_setting('watermark_text', 'tidypics');
+ if( $watermark_text ) { //get this value from the plugin settings
+ if( $thumblarge ) {
+ $ext = ".png";
+ $user_stamp_base = dirname(__FILE__) . "/" . $username . "_stamp";
+ if( !file_exists( $user_stamp_base . $ext )) { //create the watermark if it doesn't exist
+ $commands = array();
+ $commands[] = 'convert -size 300x50 xc:grey30 -pointsize 20 -gravity center -draw "fill grey70 text 0,0 \''. $watermark_text . '\'" '. $user_stamp_base . '_fgnd' . $ext;
+ $commands[] = '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[] = 'composite -compose CopyOpacity ' . $user_stamp_base . "_mask" . $ext . ' ' . $user_stamp_base . '_fgnd' . $ext . ' ' . $user_stamp_base . $ext;
+ $commands[] = 'mogrify -trim +repage ' . $user_stamp_base . $ext;
+ $commands[] = 'rm ' . $user_stamp_base . '_mask' . $ext;
+ $commands[] = 'rm ' . $user_stamp_fgnd . '_mask' . $ext;
+
+ foreach( $commands as $command ) {
+ file_put_contents("/home/gfroese/debug.txt", $command . "\n", FILE_APPEND);
+ exec( $command );
+ }
+ }
+ //apply the watermark
$commands = array();
- $commands[] = 'convert -size 300x50 xc:grey30 -pointsize 20 -gravity center -draw "fill grey70 text 0,0 \''. $watermark_text . '\'" '. $user_stamp_base . '_fgnd' . $ext;
- $commands[] = '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[] = 'composite -compose CopyOpacity ' . $user_stamp_base . "_mask" . $ext . ' ' . $user_stamp_base . '_fgnd' . $ext . ' ' . $user_stamp_base . $ext;
- $commands[] = 'mogrify -trim +repage ' . $user_stamp_base . $ext;
- $commands[] = 'rm ' . $user_stamp_base . '_mask' . $ext;
- $commands[] = 'rm ' . $user_stamp_fgnd . '_mask' . $ext;
-
+ $commands[] = 'composite -gravity south -geometry +0+10 ' . $user_stamp_base . $ext . ' ' . $thumblarge . ' ' . $thumblarge . '_watermarked';
+ $commands[] = "mv $thumblarge" . "_watermarked $thumblarge";
foreach( $commands as $command ) {
file_put_contents("/home/gfroese/debug.txt", $command . "\n", FILE_APPEND);
exec( $command );
}
}
- //apply the watermark
- $commands = array();
- $commands[] = 'composite -gravity south -geometry +0+10 ' . $user_stamp_base . $ext . ' ' . $thumblarge . ' ' . $thumblarge . '_watermarked';
- $commands[] = "mv $thumblarge" . "_watermarked $thumblarge";
- foreach( $commands as $command ) {
- file_put_contents("/home/gfroese/debug.txt", $command . "\n", FILE_APPEND);
- exec( $command );
- }
}
}
-*/
} else { //file exceeds file size limit, so delete it
$file->delete();
array_push($not_uploaded, $name);
diff --git a/languages/en.php b/languages/en.php
index 068616b6d..edf053aa5 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -20,6 +20,7 @@
'item:object:image' => "Photos",
'item:object:album' => "Albums",
'tidypics:settings:maxfilesize' => "Maximum file size in kilo bytes (KB):",
+ 'tidypics:settings:watermark' => "Enter text to appear in the watermark - ImageMagick must be selected for the image library",
'tidypics:enablephotos' => 'Enable Group Photo Albums',
'tidypics:editprops' => 'Edit Image Properties',
'tidypics:mostviewed' => 'Most viewed images',
diff --git a/views/default/settings/tidypics/edit.php b/views/default/settings/tidypics/edit.php
index 57c63683f..98f348699 100644
--- a/views/default/settings/tidypics/edit.php
+++ b/views/default/settings/tidypics/edit.php
@@ -26,4 +26,12 @@
<?php echo elgg_echo('tidypics:settings:maxfilesize'); ?>
<?php echo elgg_view('input/text', array('internalname' => 'params[maxfilesize]', 'value' => $maxfilesize)); ?>
+</p>
+<?php
+ $watermark_text = $vars['entity']->watermark_text;
+ if(!$watermark_text) $watermark_text = "";
+?>
+<p>
+ <?php echo elgg_echo('tidypics:settings:watermark'); ?>
+ <?php echo elgg_view('input/text', array('internalname' => 'params[watermark_text]', 'value' => $watermark_text)); ?>
</p> \ No newline at end of file