aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorGreg Froese <greg.froese@gmail.com>2009-05-17 13:24:17 +0000
committerGreg Froese <greg.froese@gmail.com>2009-05-17 13:24:17 +0000
commit7e09496c62e79eaaadbfdd2ee8b83602fde50497 (patch)
tree5eccb8c1465974e14f5f628dbfe6cc93f694acb7 /actions
parent6e9ec86ca3d512b6f6a2863111488ec995a197d4 (diff)
downloadelgg-7e09496c62e79eaaadbfdd2ee8b83602fde50497.tar.gz
elgg-7e09496c62e79eaaadbfdd2ee8b83602fde50497.tar.bz2
support spaces in images for resizing and watermarking, support some basic tags for watermarking
Diffstat (limited to 'actions')
-rw-r--r--actions/resize.php2
-rw-r--r--actions/upload.php20
2 files changed, 13 insertions, 9 deletions
diff --git a/actions/resize.php b/actions/resize.php
index 1c3bf2bad..bcb2ba520 100644
--- a/actions/resize.php
+++ b/actions/resize.php
@@ -98,7 +98,7 @@
$im_path = "/usr/bin/";
}
if(substr($im_path, strlen($im_path)-1, 1) != "/") $im_path .= "/";
- $command = $im_path . "convert $input_name -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." $output_name";
+ $command = $im_path . "convert \"$input_name\" -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." \"$output_name\"";
system($command);
return $output_name;
diff --git a/actions/upload.php b/actions/upload.php
index e24b48af8..ecdeb27f7 100644
--- a/actions/upload.php
+++ b/actions/upload.php
@@ -201,6 +201,7 @@
$viewer = get_loggedin_user();
$watermark_text = get_plugin_setting('watermark_text', 'tidypics');
$watermark_text = str_replace("%username%", $viewer->username, $watermark_text);
+ $watermark_text = str_replace("%sitename%", $CONFIG->sitename, $watermark_text);
if( $watermark_text ) { //get this value from the plugin settings
if( $thumblarge ) {
$ext = ".png";
@@ -209,15 +210,18 @@
$watermark_filename = preg_replace("/[^\w-]+/", "-", $watermark_filename);
$watermark_filename = trim($watermark_filename, '-');
- $user_stamp_base = dirname(__FILE__) . "/" . $viewer->name . "_" . $watermark_filename . "_stamp";
+ $user_stamp_base = strtolower(dirname(__FILE__) . "/" . $viewer->name . "_" . $watermark_filename . "_stamp");
+ $user_stamp_base = preg_replace("/[^\w-]+/", "-", $user_stamp_base);
+ $user_stamp_base = trim($user_stamp_base, '-');
+
if( !file_exists( $user_stamp_base . $ext )) { //create the watermark if it doesn't exist
$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: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_fgnd . '_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_fgnd . '_mask' . $ext . '"';
foreach( $commands as $command ) {
exec( $command );
@@ -225,8 +229,8 @@
}
//apply the watermark
$commands = array();
- $commands[] = $im_path . 'composite -gravity south -geometry +0+10 ' . $user_stamp_base . $ext . ' ' . $thumblarge . ' ' . $thumblarge . '_watermarked';
- $commands[] = "mv $thumblarge" . "_watermarked $thumblarge";
+ $commands[] = $im_path . 'composite -gravity south -geometry +0+10 "' . $user_stamp_base . $ext . '" "' . $thumblarge . '" "' . $thumblarge . '_watermarked"';
+ $commands[] = "mv \"$thumblarge" . "_watermarked\" \"$thumblarge\"";
foreach( $commands as $command ) {
exec( $command );
}