Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add auto image watermark in orchard CMS?

I use Orchard cms. I want when images uploaded, the images get watermark automatically. How can I do this?

like image 557
faezeh foroohar Avatar asked Mar 11 '23 09:03

faezeh foroohar


1 Answers

To add watermark automatically, you have to add a OnPublished handler for ImagePart as following:

OnPublished<ImagePart>((context, part) => {
    var mediaPart = part.As<MediaPart>();
    // Here you can add watermark code
});

If you want to add the watermark on the original uploaded image, you have to call it from the handler directly, but if you want to use media processing module mechanism (Which will keep the original image as is, and create a new one with filters applied and save it in _Profiles folder), then you can add a new implementation for IImageFilterProviderto add a new filter for Orchard media processing pipeline.

Finally, I recommend you to use ImageResizer.Plugins.Watermark plugin to achieve this, because Orchard already use ImageResizer component as default image processing framework.

Update: Please refer to this link for complete implementation, or this repo for source code.

like image 97
mdameer Avatar answered Mar 16 '23 03:03

mdameer