Aurigma Image Uploader 4.8 Dual
Adding Watermarks
See Also

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.

# Specifying Watermarks

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 first and second thumbnails. Note that the overlaying image is drawn semi-transparent. Here is the logo:

And here is the code:

JavaScript | Copy Code
--- | ---
    <script type="text/javascript" src="iuembed.js"></script>

    <script type="text/javascript">
    function ImageUploader_BeforeUpload() {
        getImageUploader("ImageUploader").setUploadThumbnail2Watermark("ImageUrl=" +
            "http://localhost/AurigmaLogo.png;ImageWidth=86;ImageHeight=63;" +
            "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/AurigmaLogo.png;ImageWidth=86;ImageHeight=63;" +
        "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 × 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 with semicolons. The order and case of parameters are ignored.

In our example, the following parameters are used:

- ImageUrl—sets the logo.
- Position—sets the logo position (in our case, the top right corner of the image).
- ImageWidth and ImageHeight—set the logo size (in pixels).
- Opacity—sets the opacity of the logo.

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.

Note
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:

- You can use as watermarks images in any format supported by Image Uploader.
- The image watermarks are resized in the same manner as thumbnails, that is they can only be downsized (if it is needed).
- You may specify opacity for both text and image watermarks.
- You may specify a background color for both text and image watermarks. For the image watermarks it will be used, if the image contains transparency.
- When both text and image watermarks are specified, the text is always drawn over the image watermark.
- Position of the text and image watermarks is calculated separately.

# Adding Watermarks to Original Images

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:

JavaScript | Copy Code
--- | ---
    <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>

# See Also

##### Samples

Watermark Sample

##### Reference

UploadThumbnailWatermark Property
UploadThumbnail1Watermark Property
UploadThumbnail2Watermark Property
UploadThumbnail3Watermark Property
UploadThumbnail1FitMode Property
UploadThumbnail2FitMode Property
UploadThumbnail3FitMode Property
UploadSourceFile Property
UploadThumbnailAdd Method
BeforeUpload Event