Copied to clipboard

Flag this post as spam?

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


  • Laurence Gillian 600 posts 1219 karma points
    Nov 26, 2015 @ 17:51
    Laurence Gillian
    0

    Image Cropper - Getting Original URL

    Hello,

    I'd like to get the original source URL for an Image that's stored in Umbraco.

    The problem is when I use

     return this.GetCropUrl(imageCropMode: ImageCropMode.Max);
    

    The image is returned with "?mode=max&rnd=130741876440000000" which means ImageProcessing kicks in and the quality of the outputted image is then effected (colour depth reduced).

    I'd like to just return "file.gif".

    So you can get a better understanding of what's going on, here it all is:

    public string GetSquareCrop()
        {
            // Crop Disabled
            if (this.DisableCrop) return this.Url; // call this.GetCropUrl 
    
            // Disable ImageProcessing on GIF's
            if (this.UmbracoExtension == "gif")
            {
                // this needs replacing, to just return the image url
                return this.GetCropUrl(imageCropMode: ImageCropMode.Max);
            }
    
            if (this.UmbracoFile != null) return this.GetResponsiveCropUrl("Square");
            return null;
        }
    

    Many thanks! Laurence

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Dec 01, 2015 @ 15:53
    Sebastiaan Janssen
    1

    return this.UmbracoFile? :-)

  • Rune Hem Strand 147 posts 911 karma points hq c-trib
    Dec 01, 2015 @ 16:14
    Rune Hem Strand
    1

    return this.UmbracoFile.src;?

  • Laurence Gillian 600 posts 1219 karma points
    Dec 09, 2015 @ 15:41
    Laurence Gillian
    0

    So, if I return UmbracoFile, this returns the JSON.

    So I am now taking that JSON and making it real ;-)

        public string UmbracoFile
        {
            get
            {
                var prop = this.GetPropertyValue<string>("umbracoFile");
                if (IsJson(prop))
                { 
                   dynamic d = JsonConvert.DeserializeObject(prop);
                   return d.src;
                }
                return prop;
            }
        }
    

    I assume this method is actually somewhat unrequited, and I should be able to cast the property into something that does this for me? Rather than this Dynamic wizardry! ;-)

  • James Jackson-South 489 posts 1747 karma points c-trib
    Dec 02, 2015 @ 06:45
    James Jackson-South
    1

    Hi Laurence,

    Depending on the ImageProcessor version (v2.3.0+) you might well still get the HttpModule intercepting even if you only use the original src url if you have RAMMFAR enabled in your web.config.

    Add ipignore=true to your querystring parameters and ImageProcessor will ignore the request.

    I'd love to see the input and output images if I could to see what color loss occurs.

    Cheers

    James

  • Laurence Gillian 600 posts 1219 karma points
    Dec 09, 2015 @ 15:09
    Laurence Gillian
    0

    The two URLs below, give a really good example of the quality lose, which I assume is a change in colour depth.

    Processed: 4.gif?mode=max
    Unprocessed: 4.gif

  • James Jackson-South 489 posts 1747 karma points c-trib
    Dec 10, 2015 @ 10:06
    James Jackson-South
    0

    It looks like that's caused by the quantizer used by Gifsicle in the PostProcessor. If you download the configuration project you can disable it.

    http://imageprocessor.org/imageprocessor-web/configuration/#processingconfig

Please Sign in or register to post replies

Write your reply to:

Draft