I use Orchard cms. I want when images uploaded, the images get watermark automatically. How can I do this?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With