CodeCarvings Piczard V1.2 Help
Post-Processing Filters (Automatic Image Resize, Watermark, Etc...)
Send Feedback
Image Upload - SimpleImageUpload User Control > Post-Processing Filters (Automatic Image Resize, Watermark, Etc...)

Glossary Item Box

Please see the Examples:

  • A.501 - Overview
  • A.507 - Usage example #6 (image resize + watermark)

The PostProcessingFilter property allows to set one or more image processing filter to apply to the uploaded image.
You can, for example, use this property to automatically resize an uploaded image or apply any other kind of ImageProcessingFilter.

This feature can be used in combination with the image editor (please see Controlling The WYSYWIG Image Editor Tool).
In this case it's important to note that the filter is applied to the edited image.

You can use an instance of the ImageProcessingFilterCollection to apply more than one filter.

For example:

ImageProcessingFilterCollection filter = new ImageProcessingFilterCollection();
filter.Add(new ScaledResizeConstraint(300, 300));
filter.Add(new ImageWatermark("~/MyWatermark.jpg"));
ImageUpload1.PostProcessingFilter = filter;

That is equivalent to:

ImageUpload1.PostProcessingFilter = new ScaledResizeConstraint(300, 300) + new ImageWatermark("~/MyWatermark.jpg");

A common scenario is to disable the image editor and use PostProcessingFilter to automatically process an image.
In this way, you can for example, allow a final user to upload & resize an image with a single click:

Copy Code
protected void Page_Load(object sender, EventArgs e)
{
   
if (!this.IsPostBack)
   {
       
this.ImageUpload1.EnableEdit = false;
       
this.ImageUpload1.PostProcessingFilter = new ScaledResizeConstraint(300, 300) + new ImageWatermark("~/MyWatermark.jpg", ContentAlignment.BottomRight);
   }
}

 

Other information about the PostProcessingFilter property:

  • Default value is null (no filter is applied).
  • Since the property PostProcessingFilter is saved in the control state, the value must be serializable.
    In particular the filter must implement the IJSONSerializable interface.
    For more information please see: JSON Serialization
  • This property is available since version 2.0.0 of the control.
©2013 Sergio Turolla. All Rights Reserved.