+ Reply to Thread
Results 1 to 1 of 1

Thread: Watermark and resize photos on the fly with VB.NET

  1. #1

    Watermark and resize photos on the fly with VB.NET

    I took a little time today to write a handy VB script that you can use to resize and/or watermark all your website’s photos on the fly. You don’t need to set permissions or change anything on any of your photos. This script will load a photo to your resize specifications, and then add the watermark you specify (like your company logo). You can even use it on html pages, as long as your webserver supports VB.NET. The configuration variables allow you to customize almost every aspect of the watermark like its position (top left, top right, bottom left, bottom right), opacity, background transparency and size. Other configuration variables allow you to specify the maximum size or width of your main photo and jpeg output quality. Download the VB.NET watermark file and simply change some of the variables if you like. Make sure you specify at least the path to your photo/s (strImagePath), and the watermark location (imgWatermark)

    Some Examples

    Position: Top Left, Top Right, Bottom Left, Bottom Right
    Opacity: 1, 100, 200
    Max photo width: 300px, 10% watermark size
    Max photo height: 300px, 10% watermark size
    Watermark size: 10%, 20%
    Jpeg quality: 50%

    Calling the image can’t be easier… Add the following <img> tag to your html where the src is the location where you copied the watermark.aspx file to (you can configure an image path and replace "ID" with “src”, but to prevent people from just downloading the image without the watermark, I used “ID”):

    Code:
    <img src="watermark.aspx?id=1" />
    Configuration variables

    imgWatermark – path to your watermark image (Recommended that you use a PNG8 transparent logo image, and then you can use "intWatermarkOpasity" as well)

    intSpaceFromEdge – Pixels the watermark will display from the edges of your photo
    intPercent – The size to print the watermark on your main photo. It is wise to use a larger image if you use the “bolWatermarkBackTransparent” variable. Possible Values: 1 – 100 (%)

    strPosition – Position to place your watermark on the photo. Top left, top right, bottom left, bottom right are the options available. Possible Values: tl, tr, bl, br

    bolWatermarkBackTransparent - Based on the top left pixel color of your watermark. It is recommended that you keep this setting false and set the transparency in a PNG8 watermark image file. Possible Values: True or False

    intWatermarkOpasity – The opacity for your watermark. YOU CAN NOT USE THIS if bolWatermarkBackTransparent. Possible Values: 1 – 255 (Higher value = more transparent)

    intMainImageQuality – The quality to print your photo in jpeg format. Possible Values: 1 – 100 (%)

    intMaxMainImageWidth – The maximum width to print the photo to in pixels

    intMaxMainImageHeight - The maximum height to print the photo to in pixels

    bolShowWatermark –Add or remove the watermark if you only want to resize or set the quality of your photo. Possible Values: True or False
    Attached Files
    CWA - CoolWebAwards.com

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts