$thumbname = $thumb->getFilenameOnFilestore();\r
$rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(),\r
$thumbname,\r
+ false,\r
$image_sizes['thumb_image_width'],\r
$image_sizes['thumb_image_height'], \r
true);\r
$thumbname = $thumb->getFilenameOnFilestore();\r
$rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(),\r
$thumbname,\r
+ false,\r
$image_sizes['small_image_width'],\r
$image_sizes['small_image_height'], \r
true); \r
$thumbname = $thumb->getFilenameOnFilestore();\r
$rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(),\r
$thumbname,\r
+ true,\r
$image_sizes['large_image_width'],\r
$image_sizes['large_image_height'], \r
false); \r
return false;\r
$file->largethumb = $prefix."largethumb".$filestorename;\r
\r
- tp_gd_watermark($thumbname);\r
\r
unset($thumb);\r
\r
*\r
* @param string $input_name The name of the file on the disk\r
* @param string $output_name The name of the file to be written\r
+ * @param bool - watermark this image? \r
* @param int $maxwidth The maximum width of the resized image\r
* @param int $maxheight The maximum height of the resized image\r
* @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.\r
* @return bool true on success or false on failure\r
*/\r
- function tp_gd_resize($input_name, $output_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) {\r
+ function tp_gd_resize($input_name, $output_name, $watermark, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) {\r
\r
// Get the size information from the image\r
$imgsizearray = getimagesize($input_name);\r
if (!rtn_code)\r
return $rtn_code;\r
\r
+ if ($watermark)\r
+ tp_gd_watermark($newimage);\r
+ \r
switch ($imgsizearray['mime']) {\r
case 'image/jpeg':\r
case 'image/pjpeg':\r
return $filename;
}
-function tp_gd_watermark($filename) {
+function tp_gd_watermark($image) {
+ $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);
+
+
+
+ $font = 5;
+ $line_width = strlen($watermark_text) * imagefontwidth($font);
+ $line_height = imagefontheight($font);
+
+ $image_width = 600;
+ $image_height = 450;
+
+ // matching -gravity south -geometry +0+10
+ $top = $image_height - $line_height - 10;
+ $left = round(($image_width - $line_width) / 2);
+
+ $textcolor = imagecolorallocate($image, 0, 0, 255);
+ imagestring($image, $font, $left, $top, $watermark_text, $textcolor);
}
function tp_imagick_watermark($filename) {