Copied to clipboard

Flag this post as spam?

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


  • cosminu 9 posts 103 karma points
    Jun 19, 2018 @ 06:51
    cosminu
    0

    Umbraco ImageProcessor Watermark

    Hi Everyone!

    Can you please help me out with an issue? I am using umbraco v7.10.4 and want to receive an watermarked image from the Media gallery.

    This is the code I am using in a partial view (put this together after googling a bit):

     var mediaItem = Umbraco.TypedMedia(1117);
    if (mediaItem != null)
    {
        var furtherOptions = "&watermark=MyTestWatermark&color=fff&fontsize=36&fontstyle=italic&fontopacity=80&dropshadow=true";
    
        <div class="banner"><img src="@Url.GetCropUrl(mediaItem, null, null, "umbracoFile", null, null, null, null, false,false, false, furtherOptions)" alt="img"></div>
    
    }
    

    I found that only this overload of Url.GetCropUrl allows to receive the "furtherOptions" parameter that should contain instructions for the Image Processor.

    I have checked the /config/imageProcessor config files (they are unaltered from the default installation) and seem to be configured properly.

    The issue is that I am getting the image, but no watermark whatsoever.

    Nothing in the logs to suggest any error.

    Do you have any ideas? or any better way to accomplish this (for example would have liked to be able to get the image by the name in the gallery)?

    Thank you! Cosmin

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Jun 19, 2018 @ 07:47
    Dave Woestenborghs
    101

    Hi Cosminu,

    Can you show the link that is generated for the image ?

    And can you check your config if watermark is enabled. You can check this in /config/imageprocessor/processing.config

    You will need to set enabled="true" on this line

    <plugin name="Watermark" type="ImageProcessor.Web.Processors.Watermark, ImageProcessor.Web" />
    

    Dave

  • cosminu 9 posts 103 karma points
    Jun 19, 2018 @ 07:53
    cosminu
    0

    Hi Dave!

    Many thanks!

    That "enabled=true" did the trick. Never occurred to me (the documentation on this feature is pretty slim) that each processing plugin must be enabled. Now, if I take a closer look, I can see that there are some other plugins enabled :).

    Thank you once again!

    Cosmin

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Jun 19, 2018 @ 07:57
    Dave Woestenborghs
    0

    Yep,

    Some plugins got disabled for security reasons in 7.5.0

    Some more information can be found here : https://umbraco.com/blog/umbraco-750-beta2-released/

    Dave

  • cosminu 9 posts 103 karma points
    Jun 19, 2018 @ 08:07
    cosminu
    0

    That is interesting. Now that I have enabled the watermark feature how can I protect the site from malicious requests as described in your link? Is there any thing to protect the request using a token (some parameter with some hashed value that can be double checked on the server) ?

    And another question: since all the image parameters are in the query string for the source image url, one can simply get that url and obtain the image without the watermark parameter. Any ideas on how to prevent that?

    Thank you!

    Cosmin

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Jun 19, 2018 @ 08:11
    Dave Woestenborghs
    0

    Hi cosminu,

    There is a link in the blogpost that shows you how you can validate requests coming in to image processor.

    So you could validate if the watermark is allowed : https://gist.github.com/nul800sebastiaan/dcb2da9e664dbe17c95bac235e3f87db

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft