A watermark is a text or an image printed upon an image selected for upload, which provides a simple means of adding useful information like date, time, an image author name, or a logo. With ActiveX/Java Uploader you can easily add watermarks to images before they are uploaded. Here you can use a text or an image as a watermark, specify a watermark position and opacity, and set some other watermark parameters.
This topic consists of the following sections:
To apply a watermark to user-selected images you should add a Thumbnail converter and specify its ThumbnailWatermark property. This property accepts a string containing a semicolon-separated list of watermark settings: variable1=value1;variable2=value2;...
Now, let us describe parameters which are common for graphic and text watermarks:
0
means total transparency, 100
states that a watermark is opaque.Watermark parameters are case insensitive and can be specified in any order.
If you set up both text and graphic watermarks, take into consideration that a text is always drawn above a graphic watermark.
This section tells about text watermarks. The most common text watermark is a date stamp. Other types of text watermarks are an image author name, a brief comment, and etc. You can use all the general settings with text watermarks and following text-specific properties:
"Style=Bold,Italic"
gives bold and italic
at the same time.#rrggbb
RGB value). Default value is an empty string, which allows to create only outlined text without inner fill.You also can specify background and outline of a text watermark:
The following example demonstartes how to add the text watermark, containing current system date and time, to images being uploaded:
<aur:Uploader ID="Uploader1" runat="server" > <Converters> <aur:Converter Mode="*.*=Thumbnail" ThumbnailFitMode="Fit" ThumbnailWidth="320" ThumbnailHeight="240" /> </Converters> </aur:Uploader>
protected void Page_Load(object sender, EventArgs e) { Uploader1.Converters[0].ThumbnailWatermark = "Text=" + DateTime.Now.ToString() + ";Size=20;" + "Style=Bold;FillColor=#00ff00;Opacity=60;Position=BottomRight;OffsetY=5;OffsetX=5;" + "BackgroundColor=#a6caf0;BackgroundMarginWidth=5;OutlineColor=#000080;OutlineWidth=1"; }
$uploader = new Uploader("Uploader1"); $converters = &$uploader->getConverters(); $converter = new Converter(); $converter->setMode("*.*=Thumbnail"); $converter->setThumbnailFitMode("Fit"); $converter->setThumbnailWidth(320); $converter->setThumbnailHeight(240); $converter->setThumbnailWatermark("Text=" . date("m.d.Y H:i:s") . ";Size=20;Style=Bold;" . "FillColor=#00ff00;Opacity=60;Position=BottomRight;OffsetY=5;OffsetX=5;" . "BackgroundColor=#a6caf0;BackgroundMarginWidth=5;OutlineColor=#000080;OutlineWidth=1"); $converters[] = $converter;
var currDate = new Date(); var currDateString = (currDate.getMonth()+1) + '.' + currDate.getDate() + '.' + currDate.getFullYear() + ' ' + currDate.getHours() + ':' + currDate.getMinutes() + ':' + currDate.getSeconds(); var u = $au.uploader({ id: 'Uploader1', converters: [{mode: '*.*=Thumbnail', thumbnailWidth: 320, thumbnailHeight: 240, thumbnailFitMode: 'Fit', thumbnailWatermark: 'Text=' + currDateString + ';Size=20;Style=Bold;' + 'FillColor=#00ff00;Opacity=60;Position=BottomRight;OffsetY=5;OffsetX=5;' + 'BackgroundColor=#a6caf0;BackgroundMarginWidth=5;OutlineColor=#000080;OutlineWidth=1'}] });
Usually a logo is used as a graphic watermark, however, it can be any picture. You can use all the general settings with image watermarks, but you have to specify the following three parameters, which are required for graphics watermarks:
Applying watermarks is quite easy, however, you should remember some aspects of this process:
The following example adds watermark.png
picture as a watermark to images before the upload process starts:
<aur:Uploader ID="Uploader1" runat="server" > <Converters> <aur:Converter Mode="*.*=Thumbnail" ThumbnailFitMode="Fit" ThumbnailWidth="320" ThumbnailHeight="240" ThumbnailWatermark="ImageUrl=watermark.png;Width=190;Height=60;Opacity=60;OffsetY=20" /> </Converters> </aur:Uploader>
$uploader = new Uploader("Uploader1"); $converters = &$uploader->getConverters(); $converter = new Converter(); $converter->setMode("*.*=Thumbnail"); $converter->setThumbnailFitMode("Fit"); $converter->setThumbnailWidth(320); $converter->setThumbnailHeight(240); $converter->setThumbnailWatermark("ImageUrl=watermark.png;" . "Width=190;Height=60;Opacity=60;OffsetY=20"); $converters[] = $converter;
var u = $au.uploader({ id: 'Uploader1', converters: [{mode: '*.*=Thumbnail', thumbnailWidth: 320, thumbnailHeight: 240, thumbnailFitMode: 'Fit', thumbnailWatermark: 'ImageUrl=watermark.png;Width=190;Height=60;Opacity=60;OffsetY=20'}] });
In order to add a watermark to images without resizing them:
The following example shows how to add a graphic watermark to original images:
<aur:Uploader ID="Uploader1" runat="server" > <Converters> <aur:Converter Mode="*.*=Thumbnail" ThumbnailFitMode="ActualSize" ThumbnailWatermark="ImageUrl=watermark.png;Width=190;Height=60;Opacity=60;OffsetY=20" /> </Converters> </aur:Uploader>
$uploader = new Uploader("Uploader1"); $converters = &$uploader->getConverters(); $converter = new Converter(); $converter->setMode("*.*=Thumbnail"); $converter->setThumbnailFitMode("ActualSize"); $converter->setThumbnailWatermark("ImageUrl=watermark.png;" . "Width=190;Height=60;Opacity=60;OffsetY=20"); $converters[] = $converter;
var u = $au.uploader({ id: 'Uploader1', converters: [{mode: '*.*=Thumbnail', thumbnailFitMode: 'ActualSize', thumbnailWatermark: 'ImageUrl=watermark.png;Width=190;Height=60;Opacity=60;OffsetY=20'}] });