I'm developing a Umbraco 11 / core 7 website and trying to figure out how to simply show a greyscaled image like I used to with imageprocessor like this : "&filter=greyscale".
The documentation don't give me many pointers. Is this possible?
Yes, it is the enabling the ability to send multiple different values via the querystring that would result in lots of different images being generated that is unsafe!
ImageSharp itself does have the greyscale capability built into the library.
One way I've safely enabled this kind of thing before is with a HttpModule (.net framework days) that intercepts requests and reads a 'virtual folder' name that doesnt' exist but which is actually the name of a set of transforms to apply.
eg
/images/virtual/news/2323232/image.jpg
here the module handles any request to /images/virtual
it then reads the next folder 'news'
and then gets the image from /media/2323232/image.jpg
and then I might have a set of rules for 'news' images that resizes/crops or adds greyscale
the same image could be requested by a different URL
/images/virtual/homepage/2323232/image.jpg
and the manipulations for the homepage would be applied to the image...
But yeah if you can do it in CSS! sounds like a much simpler thing in this circumstance!
ImageSharp / Umbraco 11 filter
I'm developing a Umbraco 11 / core 7 website and trying to figure out how to simply show a greyscaled image like I used to with imageprocessor like this : "&filter=greyscale".
The documentation don't give me many pointers. Is this possible?
Hi Ulrick
It looks like a similar question was asked on the Image Sharp repo, which Umbraco V10 now uses for image manipulation.
https://github.com/SixLabors/ImageSharp.Web/discussions/310
Although the option is not part of the core API, there is a link to a PR that does implement it which could be a source of inspiration for you.
Regards
Marc
Thanks Marc. That answers my question about the ( lacking ) possibility in ImageSharp.
I think I'll avoid using the PR since it's mentioned that it is unsafe.
For now I'll be using CSS since it is only greyscale and not other kinds of color toning.
Hi Ulrik
Yes, it is the enabling the ability to send multiple different values via the querystring that would result in lots of different images being generated that is unsafe!
ImageSharp itself does have the greyscale capability built into the library.
One way I've safely enabled this kind of thing before is with a HttpModule (.net framework days) that intercepts requests and reads a 'virtual folder' name that doesnt' exist but which is actually the name of a set of transforms to apply.
eg
/images/virtual/news/2323232/image.jpg
here the module handles any request to /images/virtual
it then reads the next folder 'news'
and then gets the image from /media/2323232/image.jpg
and then I might have a set of rules for 'news' images that resizes/crops or adds greyscale
the same image could be requested by a different URL
/images/virtual/homepage/2323232/image.jpg
and the manipulations for the homepage would be applied to the image...
But yeah if you can do it in CSS! sounds like a much simpler thing in this circumstance!
regards
marc
is working on a reply...