Posted by killes@www.drop.org on November 23, 2002 at 1:01am
Jump to:
| Project: | Image |
| Version: | 6.x-1.x-dev |
| Component: | gd toolkit |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Allow uploaded images to be watermarked.
composite -dissolve 20 -gravity southeast -geometry +10+10 wmk.png image.jpg watermarked.jpg
Comments
#1
look like functionality wise the same as http://drupal.org/node/view/697
(though that request might need a new kind of submittype (eg book, poll, node, QOTD) and table
im all in fav for this request.
#2
hi
hm, this is a quite old topic, but may be someone interested in watermarks on images.
i'm worked on a patch to merge watermark pictures with original ones, and after generate the preview, thumbnail and other things.
image_watermark function placed in image.inc called through the image_scale function (exactly: image_gd_watermark & image_gd_resize), after this new images generated with a watermark on it, if the image is not a thumbnail.
watermarking can be enabled on the image settings page, you can specify the path, watermark image filename, and position on it.
some picture can be found here and here and here
first of all i have modified image_gd_resize function to filter out thumbnail images...
function image_gd_resize($source, $destination, $width, $height, $label) {
....
if ($label != 'thumbnail') {
image_watermark($res,$width,$height);
}
and of course it called by this way from image.module:
if (!image_scale($source, file_create_path($destination), $size['width'], $size['height'], $size['label'])) {other changes made for settings in image.module...
$output .= form_select(t("Watermark"), "image_watermark", variable_get("image_watermark", "2"), array("1" => "enabled", "2" => "disabled"), t("Activate, or deactivate this feature. If enabled the watermark copied over the image."));$output .= form_select(t("Watermark position"), "image_watermark_pos", variable_get("image_watermark_pos", "1"), array("1" => "bottom right", "2" => "bottom left", "3" => "top right", "4" => "top left"), t("Watermark position on the image. By default: bottom right"));
$output .= form_textfield(t("Watermark path"), "image_watermark_path", variable_get("image_watermark_path", "misc"), 20, 80, t("Path to the watermark picture without ending slash, must be relative to the Drupal installation directory. By default: misc"));
$output .= form_textfield(t("Watermark filename"), "image_watermark_filename", variable_get("image_watermark_filename", "watermark.png"), 20, 80, t("The watermark picture to copy over the original picture, if enabled"));
and the two image_watermark function in image.inc...
* Merge image file with watermark
*
* @param $res Resource for merge
* @param $width The target width
* @param $height The target height
*/
function image_watermark($res, $width, $height) {
return image_toolkit_invoke('watermark', array($res, $width, $height));
}
function image_gd_watermark($res, $width, $height) {
if (variable_get("image_watermark","") == "1") {
$wf = variable_get("image_watermark_path","").'/'.variable_get("image_watermark_filename","");
if (file_exists($wf)) {
$wf_details = image_get_info($wf);
switch ($wf_details['mime_type']) {
case "image/gif":
$watermark = imageCreateFromGIF($wf);
break;
case "image/png":
$watermark = imageCreateFromPNG($wf);
break;
case "image/jpg":
$watermark = imageCreateFromJPEG($wf);
break;
}
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
if (variable_get("image_watermark_pos","") == "1") {
$dest_x = $width - $watermark_width - 5;
$dest_y = $height - $watermark_height - 5;
}
if (variable_get("image_watermark_pos","") == "2") {
$dest_x = 5;
$dest_y = $height - $watermark_height - 5;
}
if (variable_get("image_watermark_pos","") == "3") {
$dest_x = $width - $watermark_width - 5;
$dest_y = 5;
}
if (variable_get("image_watermark_pos","") == "4") {
$dest_x = 5;
$dest_y = 5;
}
imageCopyMerge($res, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imageDestroy($watermark);
}
else {
watchdog('error', 'Selected watermark image not found in the specified location (' . $wf. ') Generated without watermark!');
}
}
}
there is an older version for drupal 4.5.0, and for the latest cvs
this patch as small as possible, so may be some things what i didn't checked, so you can modify it if necessary...
#3
The pictures rather cool I must say. What about adding text instead of pictures as watermarks to pictures?
#4
I achieved this, using ˝actions˝ with workflows. the module is called imageactions.module and does all sorts of nifty stuff like greyscaleing etc. IMO that is a better approach then a built-in watermark system.
#5
Where would one find the imageactions.module? I don't see it on the Modules page.
#6
It's here:
http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/ber/image_act...
#7
Some help needed. I've installed actions and image actions modules from cvs for a v4.6.3 base. Functions are ok, I can configure the watermark action :) My problem is that I can't find a checkbox or something else (sorry, I don't know how works exactly, because lack of docs) when I create/edit an image node. How can I select which image should be watermarked, which shouldn't. Thanks!
#8
This ois not a support thread. image actions is a proof of concept, not meant for production use, and you need actions module and workflow module installed. There you configure it.
So please, develop on with this.
#9
Please help me collect the bounty: http://drupal.org/node/76069
#10
http://drupal.org/project/watermark
Not quite four years. :p
#11