Add watermark to JPEG images
In this tutorial, you implement a file processor, called WatermarkMaker, that is executed each time you upload a JPEG image in your library. The file processor adds a watermark in the top left corner of every image you upload.
You first create the file processor class and then add the file processor in the administration settings in Sitefinity CMS backend.
Implement the file processor
Create a file processor class that inherits the FileProcessorBase class. Next, implement your logic for the CanProcessFile and Process methods:
NOTE: In the code above, you also override the
Initialize(NameValueCollection config) method. The config parameter, passed to the method, lists all additional parameters that the file processor uses. In this example, font, color, and text.
Add the file processor as administration setting
- In Sitefinity CMS backend, navigate to Administration » Settings » Advanced settings.
- Expand the Libraries node and click File processors.
Click Create new.
- Enter the following:
- Save your changes.
- To add parameters to the WatermarkMaker processor, expand its node and for each of the parameters, enter the following values, and save your changes:
As a result, all images of MIME type “image/jpeg”, for example, JPEG, JPG, and JPE are processed by the WatermarkMaker file processor before being saved in the library.