Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ulrik Nedergaard 44 posts 175 karma points
    Mar 23, 2023 @ 09:32
    Ulrik Nedergaard
    0

    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?

  • Marc Goodson 2128 posts 14220 karma points MVP 8x c-trib
    Mar 25, 2023 @ 10:14
    Marc Goodson
    100

    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

  • Ulrik Nedergaard 44 posts 175 karma points
    Mar 27, 2023 @ 12:35
    Ulrik Nedergaard
    0

    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.

  • Marc Goodson 2128 posts 14220 karma points MVP 8x c-trib
    Mar 27, 2023 @ 16:30
    Marc Goodson
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft