Copied to clipboard

Flag this post as spam?

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


  • Vaidas 22 posts 65 karma points
    Oct 29, 2014 @ 13:32
    Vaidas
    1

    GetCropUrl with ImageCropMode.Pad results in black bars on the sides

    Hello everybody,

    I have a problem with figuring out how the Image Crop modes work. 

    In our system users are allowes to upload any kind of images with varying aspect ratios and dimensions. I would like to generate thumbnails that are 800 (width) x 500 (height) px. 

    To acieve this I use 

    var image = umbracoHelper.TypedMedia(Model.GetPropertyValue("logoImage"));
    imageUrl = image.GetCropUrl(height: 500, width: 800, imageCropMode:ImageCropMode.Pad);

    The problem is that it results in black bars on the images that are in JPG format and do not match this aspect ratio. 

    Is it possible to change the color of the black bars to be white?

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Oct 29, 2014 @ 13:52
    Jeavon Leopold
    104

    Hi Vaidas,

    Yes you can like this:

    image.GetCropUrl(height: 500, width: 800, imageCropMode: ImageCropMode.Pad, furtherOptions: "&bgcolor=fff");
    

    Jeavon

  • Vaidas 22 posts 65 karma points
    Oct 29, 2014 @ 14:00
    Vaidas
    0

    Hey Jeavon,

    Thank you very very much! Works like a charm now ;)

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Oct 29, 2014 @ 14:08
    Jeavon Leopold
    0

    You're welcome!

  • James Jackson-South 489 posts 1747 karma points c-trib
    Oct 29, 2014 @ 14:53
    James Jackson-South
    2

    Hola,

    For future reference the image cropper in Umbraco uses ImageProcessor. You can find the documentation for the url API here

    From there you will be able to see the full range of instructions that are supported.

    Cheers

    James

Please Sign in or register to post replies

Write your reply to:

Draft