Copied to clipboard

Flag this post as spam?

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


  • Russell McGinnis 48 posts 183 karma points
    Aug 15, 2014 @ 01:11
    Russell McGinnis
    0

    GetCropUrl not providing cropped image

    I am calling GetCropUrl("image", "HomePage") on my Model object and when I look at the src generated it is indeed showing the expected URL matching the width and height of my defined crop i.e.:

    "/media/1096/calcfeatured2-721x407.png?anchor=center&mode=crop&width=80&height=80&rnd=130525227080000000"

    However the image is renderd at its full height and width, not at 80 x 80 !

    Any ideas how to track this one down. I am seeing nothing in the log files.

    Thanks

    Russell

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Aug 15, 2014 @ 01:21
    Bjarne Fyrstenborg
    0

    Hi Russell

    If you have defined a crop with width, height and alias then this should work:

    <img src="@Model.Content.GetCropUrl("myImageProperty", "normal")" alt="" />

    where "myImageProperty" is the property alias using the image cropper and "normal" is the alias of the image crop.

    I my case the crop is 220 x 220 px and it would generate this in the image src:

    /media/1001/bjarne.jpg?crop=0.093726494922903414,0.066769109627679624,0.078894791274914708,0.31269685502068395&amp;cropmode=percentage&amp;width=220&amp;height=220&amp;rnd=130525261720000000"

    /Bjarne

  • Russell McGinnis 48 posts 183 karma points
    Aug 15, 2014 @ 01:29
    Russell McGinnis
    0

    Thanks Bjarne, I believe that I am getting the URL correctly, but the Image Cropper just isnt doing its thing!

     

    Russell

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Aug 15, 2014 @ 01:33
    Bjarne Fyrstenborg
    0

    Okay, so how large is the generated image when you look in the source / DOM?

    Perhaps try to republish the node or republish entire site from root?

  • Russell McGinnis 48 posts 183 karma points
    Aug 15, 2014 @ 01:42
    Russell McGinnis
    0

    Bjarne, I have tried it all :)

    Deleted the image and re-added it to my Articulate Post, made sure that the "HomePage" thumbnail shows up in my property editor for the post and published. Nothing changes, still get the same results.

    Going to try and get the absolute latest ImageProcessor.dll and try that.

    Russell

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Aug 15, 2014 @ 01:52
    Bjarne Fyrstenborg
    0

    Hmm okay.. Is is only the specific crop size or also other sizes?

    It could be a calculation issue..

    which version of Umbraco are you using? I am using Umbraco 7.1.4. and have defined a crop size of 220 x 220 and it seems to work fine at this size. So perhaps try to see if it also is an issue with other crop sizes and maybe if you don't use Umbraco 7.1.4 install it via WebMatrix locally, add a property using Image Cropper and the crop size and see if it still is a problem?

    /Bjarne

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 15, 2014 @ 10:15
    Jeavon Leopold
    104

    Yes, sounds like ImageProcessor.Web is not registered.

    Could be potentially a couple of things:

    If you have pre v3.2.6 then perhaps you have turned of RAMMFAR, if you have v3.2.6 or above then perhaps the HttpModule isn't registered (example here)?

    I would recommend you update to the latest of both ImageProcessor and ImageProcessor.Web from NuGet and ensure that the HttpModule is registered.

    Jeavon

  • James Jackson-South 489 posts 1747 karma points c-trib
    Aug 15, 2014 @ 12:42
    James Jackson-South
    1

    Jeavon is on the ball here. It certainly looks like the HttpModule is not registered as the generated url is correct.

    There's documentation here for ImageProcessor that indicates what should be present in your Web.Config if you have a version installed >= 3.2.6 http://imageprocessor.org/imageprocessor-web/#webconfig

    I would strongly recommend that you upgrade to the latest version anyway. Jeavon and I are pushing for the next Umbraco release (7.1.5) to include the latest versions also.

  • Russell McGinnis 48 posts 183 karma points
    Aug 15, 2014 @ 17:37
    Russell McGinnis
    0

    Jeavon, James, thanks for the help... my web.config file was indeed missing the HttpModule registration.

    I was already running v3.2.6 on Umbraco 7.1.4

  • James Jackson-South 489 posts 1747 karma points c-trib
    Aug 15, 2014 @ 18:38
    James Jackson-South
    0

    Awesome. Glad you got it worked out :)

  • Jeric 122 posts 192 karma points
    Sep 26, 2014 @ 19:43
    Jeric
    0

    I'm using GetCropUrl, everything works fine, but the "quality:" settings bit. It doesn't matter what value i set them, as in "quality:90" or "quality:65",

    mine seems to generate the image with the same image file size. Any idea on this?
    I've installed the latest nuget as well it's still the same

     

    Any help will be great 

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Sep 26, 2014 @ 19:46
    Jeavon Leopold
    0

    Just to be clear, when you change the quality parameter is the querystring value &quality=xx changing in the rendered html?

  • Jeric 122 posts 192 karma points
    Sep 26, 2014 @ 20:23
    Jeric
    0

    yup the querystring value do change in the html. The weirdest thing is. The uploaded image is 1.29MB, Thought it will compress the image with lower quality set as "quality:90", but it rendered at 1.68MB

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Sep 26, 2014 @ 20:25
    Jeavon Leopold
    0

    Can you post the whole image path & querystring and also what dimensions is your original source image?

  • Jeric 122 posts 192 karma points
    Sep 26, 2014 @ 21:13
    Jeric
    0

    The image path will be
    /media/1150/banner_city.png?center=0.344,0.975&mode=crop&quality=70&width=1600&height=499&rnd=130562233520000000

    The original source image size is 1600 width and 499 height

     

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Sep 26, 2014 @ 21:31
    Jeavon Leopold
    0

    I think that might be bacause your source is png, try adding format=jpg and see if the quality adjusts the size

  • Jeric 122 posts 192 karma points
    Sep 27, 2014 @ 09:39
    Jeric
    0

    had tested with a jpg and it can compress the image.

    Any way i can render the GetCropUrl as jpg even though the user uploads a png (so that the image compression works?)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Sep 27, 2014 @ 09:48
    Jeavon Leopold
    0

    Yes, something like this

    <img src="@featureImage.GetCropUrl(270, 161, quality:70, furtherOptions:"&format=jpg")" alt="" />
    
  • Jeric 122 posts 192 karma points
    Sep 27, 2014 @ 09:49
    Jeric
    0

    thanks Jeavon, i'll test it out this afternoon

  • AmandaEly 123 posts 379 karma points
    Nov 26, 2014 @ 14:43
    AmandaEly
    0

    I am having the same problem as everyone else here. Currently I have an exception on the following line

    var imageCrops = JsonConvert.DeserializeObject<ImageCropDataSet>(Model.Content.GetPropertyValue<string>("picture"));

    An exception of type 'System.ArgumentNullException' occurred in Newtonsoft.Json.dll but was not handled in user code

     

    Since I don't understand how the image cropper is working, throwing more lines of code which I do not understand at it, and which crash, does not help. Sorry.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Nov 26, 2014 @ 17:17
    Jeavon Leopold
    0

    Hi Amanda,

    Why are you trying to get the crop model manually rather than using the GetCropUrl method?

    Jeavon

  • Ankur 10 posts 80 karma points
    Jul 28, 2016 @ 14:22
    Ankur
    0

    Hi,

    I have the same problem, I just cant get the image cropper to work.

    <div>1: @Model.Content.GetCropUrl("heroImage", "PageHeader")</div>

    This prints 1:

    If try this : - <div>2: @Model.heroImage</div>, I get this

    2: {   "focalPoint": {     "left": 0.53166666666666662,     "top": 0.3888888888888889   },   "src": "/media/73518/selling-your-home-cedar-shingle-home11.jpg",   "crops": [     {       "alias": "PageHeader",       "width": 610,       "height": 160,       "coordinates": {         "x1": 0,         "y1": 0.45852822580645164,         "x2": 0,         "y2": 0.0811092916205951       }     }   ] }
    

    Can you please help. I am running umbraco 7.4.3

    Regards Ankur

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 28, 2016 @ 14:34
    Jeavon Leopold
    0

    Hi Ankur,

    Try

    @Model.Content.GetCropUrl(propertyAlias: "heroImage", height: 300, width: 400)
    

    Does it give you anything?

    Jeavon

  • Ankur 10 posts 80 karma points
    Jul 28, 2016 @ 14:42
    Ankur
    0

    Nopes, it gives blank.

    Regards Ankur

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 28, 2016 @ 14:43
    Jeavon Leopold
    0

    Is this code in a MVC View? Model.heroImage sounds like it could be a legacy MacroScript...?

  • Ankur 10 posts 80 karma points
    Jul 28, 2016 @ 14:51
    Ankur
    0

    Not sure, I am not too familiar with Umbraco terminology.

    To give a bit of background, the site was in Umbraco 4.11.X and I upgraded it to umbraco 7.4.3. Rest all I have been able to make work but this image cropper and 1 issue with replace ucomponent with archtype has driven me crazy.

    Regarding the current code it resides in one of master pages under the folder /masterpages, the file name is ContentMaster.master .

    I am able to display normal images, I am having issue only with croppers.

    Here is more of the code snippet, may be this will help you understand the issue.

    @Model.Content.GetCropUrl(propertyAlias: "heroImage", height: 300, width: 400)
    }
    

    Regards Ankur

  • Ankur 10 posts 80 karma points
    Jul 28, 2016 @ 14:57
    Ankur
    0

    The code isn't pasting properly here.

    Regards Ankur

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 28, 2016 @ 15:49
    Jeavon Leopold
    0

    I'm pretty sure you are editing a MacroScript which are supported for legacy only and the GetCropUrl method is not supported. You will need to convert to a MacroPartialView then it would work.

  • Ankur 10 posts 80 karma points
    Jul 29, 2016 @ 08:39
    Ankur
    0

    I am sure you must be right, now I am trying to call the crop through the MacroPartialView. But when I call the new macro using

    <umbraco:Macro Alias="PageHeader" runat="server" />
    

    I get following error.

        Error loading Partial View (file: ~/Views/MacroPartials/PageHeader.cshtml)
    

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ffe8a1a8\a140437f\AppWebpageheader.cshtml.d673bf47.ah4sh4gj.0.cs(33): error CS0234: The type or namespace name 'PublishedContentModels' does not exist in the namespace 'Umbraco.Web' (are you missing an assembly reference?)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 29, 2016 @ 08:52
    Jeavon Leopold
    0

    Could you please post the contents of PageHeader.cshtml?

  • Ankur 10 posts 80 karma points
    Jul 29, 2016 @ 09:11
    Ankur
    0

    Here it is

    @inherits Umbraco.Web.Macros.PartialViewMacroPage @{ <div>@Model.Content.GetCropUrl(propertyAlias: "heroImage", height: 300, width: 400)</div>}  
    
  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 29, 2016 @ 09:14
    Jeavon Leopold
    0

    Should just be like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    <div>
         @Model.Content.GetCropUrl(propertyAlias: "heroImage", height: 300, width: 400)
    </div>
    
  • Ankur 10 posts 80 karma points
    Jul 29, 2016 @ 09:20
    Ankur
    0

    Same error:

    Error loading partial view macro (View: ~/Views/MacroPartials/PageHeader.cshtml)
    

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ffe8a1a8\a140437f\AppWebpageheader.cshtml.d673bf47.pv1z-nkl.0.cs(33): error CS0234: The type or namespace name 'PublishedContentModels' does not exist in the namespace 'Umbraco.Web' (are you missing an assembly reference?)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 29, 2016 @ 09:42
    Jeavon Leopold
    1

    That's coming from ModelsBuilder, are you using it? You could disable it in web.config or otherwise add

    @using Umbraco.Web.PublishedContentModel;
    
  • Ankur 10 posts 80 karma points
    Jul 29, 2016 @ 10:11
    Ankur
    0

    Did both, I still get the same error.

  • Ankur 10 posts 80 karma points
    Jul 29, 2016 @ 11:57
    Ankur
    0

    The issue comes whenever I call any MacroPartialView, even if I create an empty one.

    Regards Ankur

  • Ankur 10 posts 80 karma points
    Jul 30, 2016 @ 15:47
    Ankur
    0

    Finally resolved :). Thanks Jeavon. The partial view macro worked , the PublishedContentModel issue was because in the web.config under the folder view was adding it as a namespace. All good now :) Thanks.

    Regards Ankur

Please Sign in or register to post replies

Write your reply to:

Draft