A watermark is a text or an image which is printed upon the image, and provides a simple means of adding useful information like date and time or the name of the image author or some logo. With Image Uploader you can easily add watermarks to thumbnails of images you upload, and each of the thumbnails can have its own watermark.
There are two ways to add watermarks: using the initialization parameter or setting the corresponding property of Image Uploader object itself in runtime. The following example demonstrates how to use both approaches to put a logo on all the first and second thumbnails. Note that the overlaying image is drawn semi-transparent. Here is the logo:
And here is the code:
<script type="text/javascript" src="iuembed.js"> </script> <script type="text/javascript"> function ImageUploader_BeforeUpload() { getImageUploader("ImageUploader").setUploadThumbnail2Watermark("ImageUrl=" + "http://localhost/Watermark.png;ImageWidth=229;ImageHeight=60;" + "Position=TopRight;Opacity=50"); } var iu = new ImageUploaderWriter("ImageUploader", 710, 500); //...Any other params or event handlers... iu.addParam("UploadThumbnail1FitMode", "Fit"); iu.addParam("UploadThumbnail2FitMode", "Fit"); iu.addParam("UploadThumbnail1Watermark", "ImageUrl=http://localhost/Watermark.png;ImageWidth=229;ImageHeight=60;" + "Position=TopRight;Opacity=50"); iu.addEventListener("BeforeUpload", "ImageUploader_BeforeUpload"); //...Any other params or event handlers... iu.writeHtml(); </script>
If both thumbnails have the size of 320 x 240 pixels, we will get the following result:
As you see, the UploadThumbnail1Watermark and UploadThumbnail2Watermark properties specify a watermark as a string, which consists of several parameters separated by semicolons. The order and case of parameters are ignored.
In our example, the following parameters are used:
There are other parameters, and their descriptions may be found in the reference.
You may also add watermarks to specific thumbnails using the UploadThumbnailWatermark property.
Remember that by default Image Uploader provides only three thumbnails for each image. If you need more thumbnails, use the UploadThumbnailAdd() method.
As you may see, applying watermarks is rather easy. However, you should remember some things about this process:
If you need to add watermarks to original images, you can use the ActualSize fit mode for one of thumbnails and turn off original file upload. In order to do that, add the following parameters when initializing Image Uploader:
<script type="text/javascript" src="iuembed.js"> </script> <script type="text/javascript"> var iu = new ImageUploaderWriter("ImageUploader", 710, 500); //...Any other params or event handlers... iu.addParam("UploadThumbnail3FitMode", "Fit"); iu.addParam("UploadThumbnail3FitMode", "ActualSize"); iu.addParam("UploadSourceFile", "false"); //...Any other params or event handlers... iu.writeHtml(); </script>