diff --git a/e107_admin/image.php b/e107_admin/image.php
index 276552860..c31cbcf23 100644
--- a/e107_admin/image.php
+++ b/e107_admin/image.php
@@ -576,10 +576,24 @@ class media_admin_ui extends e_admin_ui
- Import into Category: ".$frm->selectbox('batch_category',$this->cats)."
+ Import into Category: ".$frm->selectbox('batch_category',$this->cats);
+
+ $waterMarkPath = e_THEME.e107::getPref('sitetheme')."/images/watermark.png";
+
+ if(is_readable($waterMarkPath))
+ {
+ $text .= $frm->checkbox_label("Add Watermark", 'batch_import_watermark',1);
+ }
+
+ $text .= "
- ".$frm->admin_button('batch_import_selected', "Import Selected Files", 'import')."
+ ".$frm->admin_button('batch_import_selected', "Import Selected Files", 'import');
+
+
+
+
+ $text .= "
@@ -609,6 +623,17 @@ class media_admin_ui extends e_admin_ui
require(e_HANDLER.'phpthumb/ThumbLib.inc.php'); // For resizing on import.
list($img_import_w,$img_import_h) = explode("x",e107::getPref('img_import_resize'));
+
+ if(vartrue($_POST['batch_import_watermark']))
+ {
+ $WM = TRUE;
+ $watermarkPath = e_THEME.e107::getPref('sitetheme')."/images/watermark.png";
+ $watermark = PhpThumbFactory::create($watermarkPath);
+ }
+ else
+ {
+ $WM = FALSE;
+ }
foreach($_POST['batch_selected'] as $file)
{
@@ -626,9 +651,19 @@ class media_admin_ui extends e_admin_ui
catch (Exception $e)
{
$mes->addError($e->getMessage());
+ continue;
// return $this;
}
- $thumb->resize($img_import_w,$img_import_h)->save($oldpath);
+ if($WM) // TODO Add watermark prefs for alpha and position.
+ {
+ $thumb->resize($img_import_w,$img_import_h)->addWatermark($watermark, 'rightBottom', 30, 0, 0)->save($oldpath);
+
+ }
+ else
+ {
+ $thumb->resize($img_import_w,$img_import_h)->save($oldpath);
+ }
+
}
// End Resize routine. ---------------------
diff --git a/e107_handlers/phpthumb/thumb_plugins/gd_watermark.inc.php b/e107_handlers/phpthumb/thumb_plugins/gd_watermark.inc.php
new file mode 100644
index 000000000..50f33273a
--- /dev/null
+++ b/e107_handlers/phpthumb/thumb_plugins/gd_watermark.inc.php
@@ -0,0 +1,100 @@
+addWatermark($watermark, 'rightBottom', 50, 0, 0);
+ * $pic->show(); //or $pic->save('path/to/new/pic/destination');
+ * ?>
+ *
+ * PHP Version 5 with GD 2.0+
+ * PhpThumb : PHP Thumb Library
+ * Copyright (c) 2009, Ian Selby/Gen X Design
+ *
+ * Author(s): Ian Selby
+ *
+ * Licensed under the MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @author Thomas Dullnig
+ * @copyright Copyright (c) 2009-2010 SEVENSPIRE
+ * @link http://www.sevenspire.com
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ * @version 1.0
+ * @package PhpThumb
+ * @filesource
+ */
+
+/**
+ * GD Watermark Lib Plugin
+ *
+ * Overlays an image with another image to create a watermark-effect
+ *
+ * @package PhpThumb
+ * @subpackage Plugins
+ */
+class GdWatermark
+{
+ /**
+ * Function copied from: http://www.php.net/manual/en/function.imagecopymerge.php#92787
+ * Does the same as "imagecopymerge" but preserves the alpha-channel
+ */
+ protected function imageCopyMergeAlpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct){
+ $cut = imagecreatetruecolor($src_w, $src_h);
+ imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
+ imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
+ imagecopymerge($dst_im, $cut, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct);
+ }
+
+ /**
+ * Adds a watermark to the current image and overlays it on the given position.
+ * @param object $wm a GdThumb-Object
+ * @param object $pos Can be: left/west, right/east, center for the x-axis and top/north/upper, bottom/lower/south, center for the y-axis
+ * Examples:
+ * - leftTop/leftop/topleft/topLeft same as westNorth same as westupper same as leftnorth or any other combination
+ * - center --> centers both the x- and y-axis
+ * - leftCenter --> set x-axis to the left corner of the image and centers the y-axis
+ * @param object $opacity
+ * - set the opacity of the watermark in percent, 0 = total transparent, 100 = total opaque
+ * @param object $offsetX
+ * - add an offset on the x-axis. can be negative to set an offset to the left
+ * @param object $offsetY
+ * - add an offset on the y-axis. can be negative to set an offset to the top
+ * @param object $that
+ * - the current GdThumb-Object
+ * @return the manipulated GdThumb-Object for chaining
+ */
+ public function addWatermark($wm, $pos, $opacity, $offsetX, $offsetY, $that) // dont use &wm etc.
+ {
+ $picDim = $that->getCurrentDimensions();
+ $wmDim = $wm->getCurrentDimensions();
+
+ $wmPosX = $offsetX;
+ $wmPosY = $offsetY;
+
+ if(preg_match('/right|east/i', $pos)){$wmPosX += $picDim['width'] - $wmDim['width'];}
+ else if(!preg_match('/left|west/i', $pos)){$wmPosX += intval($picDim['width']/2 - $wmDim['width']/2);}
+
+ if(preg_match('/bottom|lower|south/i', $pos)){$wmPosY += $picDim['height'] - $wmDim['height'];}
+ else if(!preg_match('/upper|top|north/i', $pos)){$wmPosY += intval($picDim['height']/2 - $wmDim['height']/2);}
+
+ $workingImage = $that->getWorkingImage();
+ $wmImage = ($wm->getWorkingImage() ? $wm->getWorkingImage() : $wm->getOldImage());
+
+ $this->imageCopyMergeAlpha($workingImage, $wmImage, $wmPosX, $wmPosY, 0, 0, $wmDim['width'], $wmDim['height'], $opacity);
+
+ $that->setWorkingImage($workingImage);
+
+ return $that;
+ }
+}
+
+$pt = PhpThumb::getInstance();
+$pt->registerPlugin('GdWatermark', 'gd');