diff options
-rw-r--r-- | languages/da.php | 1 | ||||
-rw-r--r-- | languages/de.php | 1 | ||||
-rw-r--r-- | languages/en.php | 1 | ||||
-rw-r--r-- | languages/es.php | 1 | ||||
-rw-r--r-- | languages/fr.php | 1 | ||||
-rw-r--r-- | languages/he.php | 1 | ||||
-rw-r--r-- | lib/resize.php | 17 | ||||
-rw-r--r-- | lib/watermark.php | 193 | ||||
-rw-r--r-- | views/default/forms/photos/admin/settings/main.php | 8 |
9 files changed, 1 insertions, 223 deletions
diff --git a/languages/da.php b/languages/da.php index 78113d467..37ab3bfc6 100644 --- a/languages/da.php +++ b/languages/da.php @@ -63,7 +63,6 @@ $danish = array( 'tidypics:settings:grp_perm_override' => "Giv gruppens medlemmer fuld adgang til gruppe-album",
'tidypics:settings:maxfilesize' => "Maksimal billedstørrelse i megabytes (MB):",
'tidypics:settings:quota' => "Tildelt plads til brugere / grupper (MB) (0 = Ingen plads)",
- 'tidypics:settings:watermark' => "Indtast teksten for vandmærke - ImageMagick cmdline skal vælges for billedbiblioteket",
'tidypics:settings:im_path' => "Angiv stien til ImageMagick kommandoer (som slutter med et Slash/)",
'tidypics:settings:img_river_view' => "Hvor mange poster i aktivitetslisten for hvert parti af uploadede billeder",
'tidypics:settings:album_river_view' => "Vis albumcover eller et sæt af fotos til nye album",
diff --git a/languages/de.php b/languages/de.php index 1f439e981..a02f34f89 100644 --- a/languages/de.php +++ b/languages/de.php @@ -72,7 +72,6 @@ $german = array( 'tidypics:settings:grp_perm_override' => "Gruppen-Mitgliedern unbeschränkten Zugriff auf die Verwaltung von Gruppen-Alben geben",
'tidypics:settings:maxfilesize' => "Maximal erlaubte Bildgröße in Megabytes (MB):",
'tidypics:settings:quota' => "Quota für Benutzer in Megabytes (MB) (0 = kein Quota)",
- 'tidypics:settings:watermark' => "Gib den Text ein, der als Wasserzeichen eingefügt wird",
'tidypics:settings:im_path' => "Der Pfad zu den ImageMagick-Kommandozeilentools auf dem Server",
'tidypics:settings:img_river_view' => "Anzahl der Einträge im River beim gleichzeitigen Hochladen mehrerer Bilder",
'tidypics:settings:album_river_view' => "Anzeige des Albumcovers oder eines Sets von Bildern für neue Alben",
diff --git a/languages/en.php b/languages/en.php index 62b43673d..6f3f8a0d6 100644 --- a/languages/en.php +++ b/languages/en.php @@ -72,7 +72,6 @@ $english = array( '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 Quota (MB) - 0 equals no quota", - 'tidypics:settings:watermark' => "Enter text to appear in the watermark", 'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands", 'tidypics:settings:img_river_view' => "How many entries in activity 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/languages/es.php b/languages/es.php index 704f01979..b6cbf723c 100644 --- a/languages/es.php +++ b/languages/es.php @@ -59,7 +59,6 @@ $spanish = array( 'tidypics:settings:grp_perm_override' => "Permitir acceso completo a los miembros de este grupo al album de fotos",
'tidypics:settings:maxfilesize' => "Tamaño máximo de la imagen en megabytes (MB):",
'tidypics:settings:quota' => "Usuario/Grupo Cuota (MB) - 0 MB de cuota",
- 'tidypics:settings:watermark' => "Introduce el texto que aparecerá en la marca de agua - ImageMagick Cmdline debe ser seleccionado para la libreria de imagenes",
'tidypics:settings:im_path' => "Ingresa la ruta de tu ImageMagick commands (incluye el slash)",
'tidypics:settings:img_river_view' => "¿Cuántas entradas deseas para cada grupo de imágenes cargadas?",
'tidypics:settings:album_river_view' => "Muestra la portada del álbum o el set de fotos para el álbum nuevo",
diff --git a/languages/fr.php b/languages/fr.php index 375159e0b..0ca141ea2 100644 --- a/languages/fr.php +++ b/languages/fr.php @@ -59,7 +59,6 @@ $french = array( 'tidypics:settings:grp_perm_override' => "Autoriser l'acés total aux membres du groupe" , 'tidypics:settings:maxfilesize' => "Taille maximum des images en Mb:" , 'tidypics:settings:quota' => "Quota Utilisateur/Groupe (Mb) - O égal pas de quota" , - 'tidypics:settings:watermark' => "Entrez le texte qui doit figure sur le WaterMark - fonction non vraiment sure." , 'tidypics:settings:im_path' => "Chemin de l'exécutable ImageMagick, terminé par un slash" , 'tidypics:settings:img_river_view' => "Combien d'entrées dans le river pour chaque lot de traitement des fichiers chargés" , 'tidypics:settings:album_river_view' => "Montrer la couverture de l'album ou un ensemble de photos pour tout nouvel album" , diff --git a/languages/he.php b/languages/he.php index 5f232daf6..ebb3608aa 100644 --- a/languages/he.php +++ b/languages/he.php @@ -54,7 +54,6 @@ $hebrew = array( 'tidypics:settings:grp_perm_override' => "אפשר לחברי קבוצה גישה מלאה לאלבומים קבוצתיים" , 'tidypics:settings:maxfilesize' => "גודל תמונה מירבי בMB" , 'tidypics:settings:quota' => "מכסה בMB למשתמש/קבוצה - 0 שווה ללא מכסה" , - 'tidypics:settings:watermark' => "הזן טקסט אשר יופיע בסימן המים - יש לבחור ב ImageMagick Cmdline עבור ספריית התמונות" , 'tidypics:settings:im_path' => "הזן את הנטיב לפקודות ImageMagick ללא לוכסן בסוף" , 'tidypics:settings:img_river_view' => "כמה רשומות במה חדש עבור כל מקבץ תמונות אשר נוסף" , 'tidypics:settings:album_river_view' => "הצג תמונה אחת או מקבץ תמונות עבור אלבום חדש" , diff --git a/lib/resize.php b/lib/resize.php index b06f317ca..380e0c406 100644 --- a/lib/resize.php +++ b/lib/resize.php @@ -5,8 +5,6 @@ * @package TidypicsImageResize */ -include dirname(__FILE__) . "/watermark.php"; - /** * Create thumbnails using PHP GD Library @@ -37,7 +35,6 @@ function tp_create_gd_thumbnails($file, $prefix, $filestorename) { $thumbname = $thumb->getFilenameOnFilestore(); $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), $thumbname, - FALSE, $image_sizes['tiny_image_width'], $image_sizes['tiny_image_height'], TRUE); @@ -53,7 +50,6 @@ function tp_create_gd_thumbnails($file, $prefix, $filestorename) { $thumbname = $thumb->getFilenameOnFilestore(); $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), $thumbname, - FALSE, $image_sizes['small_image_width'], $image_sizes['small_image_height'], TRUE); @@ -68,7 +64,6 @@ function tp_create_gd_thumbnails($file, $prefix, $filestorename) { $thumbname = $thumb->getFilenameOnFilestore(); $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), $thumbname, - TRUE, $image_sizes['large_image_width'], $image_sizes['large_image_height'], FALSE); @@ -89,13 +84,12 @@ function tp_create_gd_thumbnails($file, $prefix, $filestorename) { * * @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, $watermark, $maxwidth, $maxheight, $square = FALSE, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { +function tp_gd_resize($input_name, $output_name, $maxwidth, $maxheight, $square = FALSE, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { // Get the size information from the image $imgsizearray = getimagesize($input_name); @@ -159,10 +153,6 @@ function tp_gd_resize($input_name, $output_name, $watermark, $maxwidth, $maxheig return $rtn_code; } - if ($watermark) { - tp_gd_watermark($newimage); - } - switch ($imgsizearray['mime']) { case 'image/jpeg': case 'image/pjpeg': @@ -243,8 +233,6 @@ function tp_create_imagick_thumbnails($file, $prefix, $filestorename) { } $file->largethumb = $prefix."largethumb".$filestorename; - tp_imagick_watermark($thumbname); - unset($thumb); return TRUE; @@ -370,9 +358,6 @@ function tp_create_im_cmdline_thumbnails($file, $prefix, $filestorename) { } $file->largethumb = $prefix."largethumb".$filestorename; - - tp_im_cmdline_watermark($thumbname); - unset($thumb); return TRUE; diff --git a/lib/watermark.php b/lib/watermark.php deleted file mode 100644 index f7c228af1..000000000 --- a/lib/watermark.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php -/** - * Watermarking functions - * - * @package TidypicsWatermark - */ - -/** - * Make replacements in watermark text - * - * @param string $text - * @param ElggUser $owner - * @return string - */ -function tp_process_watermark_text($text, $owner) { - global $CONFIG; - - $text = str_replace("%name%", $owner->name, $text); - $text = str_replace("%sitename%", $CONFIG->sitename, $text); - - return $text; -} - -/** - * Create the watermark image filename - * - * @param string $text - * @param ElggUser $owner - * @return string - */ -function tp_get_watermark_filename($text, $owner) { - - $base = elgg_strtolower($text); - $base = preg_replace("/[^\w-]+/", "-", $base); - $base = trim($base, '-'); - - $filename = tp_get_img_dir(); - $filename .= elgg_strtolower($owner->username . "_" . $base . "_stamp"); - - return $filename; -} - -/** - * Use GD to apply watermark to image - * - * @param resource $image GD image resource - */ -function tp_gd_watermark($image) { - global $CONFIG; - - $watermark_text = elgg_get_plugin_setting('watermark_text', 'tidypics'); - if (!$watermark_text) { - return; - } - - // plugins can do their own watermark and return false to prevent this function from running - if (elgg_trigger_plugin_hook('tp_watermark', 'gd', $image, true) === false) { - return; - } - - $owner = elgg_get_logged_in_user_entity(); - - $watermark_text = tp_process_watermark_text($watermark_text, $owner); - - // transparent gray - imagealphablending($image, true); - $textcolor = imagecolorallocatealpha($image, 50, 50, 50, 60); - - // font and location - $font = $CONFIG->pluginspath . "tidypics/fonts/LiberationSerif-Regular.ttf"; - $bbox = imagettfbbox(20, 0, $font, $watermark_text); - - $text_width = $bbox[2] - $bbox[0]; - $text_height = $bbox[1] - $bbox[7]; - - $image_width = imagesx($image); - $image_height = imagesy($image); - - $left = $image_width / 2 - $text_width / 2; - $top = $image_height - 20; - - // write the text on the image - imagettftext($image, 20, 0, $left, $top, $textcolor, $font, $watermark_text); -} - -/** - * imagick watermarking - * - * @param string $filename - * @return bool - */ -function tp_imagick_watermark($filename) { - - $watermark_text = elgg_get_plugin_setting('watermark_text', 'tidypics'); - if (!$watermark_text) { - return false; - } - - // plugins can do their own watermark and return false to prevent this function from running - if (elgg_trigger_plugin_hook('tp_watermark', 'imagick', $filename, true) === false) { - return true; - } - - $owner = elgg_get_logged_in_user_entity(); - - $watermark_text = tp_process_watermark_text($watermark_text, $owner); - - $img = new Imagick($filename); - - $img->readImage($image); - - $draw = new ImagickDraw(); - - //$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; -} - -/** - * ImageMagick watermarking - * - * @param string $filename - */ -function tp_im_cmdline_watermark($filename) { - - $watermark_text = elgg_get_plugin_setting('watermark_text', 'tidypics'); - if (!$watermark_text) { - return; - } - - // plugins can do their own watermark and return false to prevent this function from running - if (elgg_trigger_plugin_hook('tp_watermark', 'imagemagick', $filename, true) === false) { - return; - } - - $im_path = elgg_get_plugin_setting('im_path', 'tidypics'); - if (!$im_path) { - $im_path = "/usr/bin/"; - } - - // make sure end of path is / - if (substr($im_path, strlen($im_path)-1, 1) != "/") { - $im_path .= "/"; - } - - - $owner = elgg_get_logged_in_user_entity(); - - $watermark_text = tp_process_watermark_text($watermark_text, $owner); - - $ext = ".png"; - - $user_stamp_base = tp_get_watermark_filename($watermark_text, $owner); - - - if ( !file_exists( $user_stamp_base . $ext )) { - //create the watermark image 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: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 ); - } - } - - //apply the watermark - $commands = array(); - $commands[] = $im_path . 'composite -gravity south -geometry +0+10 "' . $user_stamp_base . $ext . '" "' . $filename . '" "' . $filename . '_watermarked"'; - $commands[] = "mv \"$filename" . "_watermarked\" \"$filename\""; - foreach( $commands as $command ) { - exec( $command ); - } -} diff --git a/views/default/forms/photos/admin/settings/main.php b/views/default/forms/photos/admin/settings/main.php index c99b9d688..c2ae523c1 100644 --- a/views/default/forms/photos/admin/settings/main.php +++ b/views/default/forms/photos/admin/settings/main.php @@ -27,14 +27,6 @@ echo elgg_view('input/text', array( )); echo '</div>'; -// Watermark Text -echo '<div>' . elgg_echo('tidypics:settings:watermark'); -echo elgg_view("input/text", array( - 'name' => 'params[watermark_text]', - 'value' => $plugin->watermark_text, -)); -echo '</div>'; - // Quota Size $quota = $plugin->quota; if (!$quota) { |