Copied to clipboard

Flag this post as spam?

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


This forum is in read only mode, you can no longer reply
  • Tom Steer 161 posts 596 karma points
    Aug 13, 2015 @ 15:20
    Tom Steer
    0

    Resize pad with max image size

    Hey,

    Say I had an image which is 200x200, is it possible to resize it to be 500x500 but not upscale the image only pad it. I have tried a few things but couldn't seem to get it to work it either didn't resize to be 500x500 or it would upscale the image (stretch).

    This is an example of two things I've tried:

    5069a.jpg?mode=pad&width=500&height=500&anchor=top&bgcolor=fff

    ?mode=pad&width=500&height=500&anchor=top&bgcolor=fff&upscale=false

    Cheers :)

    Tom

  • James Jackson-South 489 posts 1747 karma points c-trib
    Aug 13, 2015 @ 21:07
    James Jackson-South
    0

    Hi Tom.

    I'm afraid not out of the box. ImageProcessor.Web handles only one resize instruction per request.

    You could however extend the solution by creating your own IWebGraphicsProcessor called Pad which would do it. There's tons of example code on GitHub to show you how this works.

    Maybe you could contribute that back to the core if you took that approach. :)

    Hope that helps.

    James

  • Tom Steer 161 posts 596 karma points
    Aug 20, 2015 @ 15:43
    Tom Steer
    0

    Hey James,

    Thank you for getting back to me :)

    I've modified the source of ImageProcessor now so it behaves how I mentioned above. Would be cool to run it passed you, if you fancied it (see if it's worthy of going back into the core after some tidying up :) )?

    Cheers,

    Tom

  • James Jackson-South 489 posts 1747 karma points c-trib
    Aug 20, 2015 @ 22:58
    James Jackson-South
    0

    Hi Tom,

    Yeah, I'd absolutely love to look at your code. Is it in a fork on Github?

    Cheers

    James

  • Tom Steer 161 posts 596 karma points
    Aug 21, 2015 @ 19:17
    Tom Steer
    0

    Hey James,

    Yeah you can find it here:

    https://github.com/TomSteer/ImageProcessor

    I didn't take the route of creating my own IWebGraphicsProcessor, instead I ended up editing the Resizer class and used the upscale flag to decide whether the source image should be resized or just the canvas when using ResizeMode.Pad. This seemed like the correct way to me (settings wise). Apologies if it is wrong, happy to hear your feedback if so :)

    Many Thanks,

    Tom

  • Tom Steer 161 posts 596 karma points
    Sep 02, 2015 @ 06:12
    Tom Steer
    0

    Hey James,

    Have you had a chance to have a look at my change yet? Would love to get this functionality in image processor some way or other :) happy to relook at it if you don't think Ive gone about it in the best way or if it causes a breaking change.

    Cheers,

    Tom

  • James Jackson-South 489 posts 1747 karma points c-trib
    Sep 02, 2015 @ 08:37
    James Jackson-South
    0

    Hi Tom, sorry for not getting back sooner.

    Changing the behaviour of upscale will cause a breaking change so I'll have to approach it differently. I'm thinking of adding an additional value to the ResizeMode enum - BoxPad or something and setting the logic like that. Keep your code online please so I can steal what maths you've done.

    Cheers!

    James

  • James Jackson-South 489 posts 1747 karma points c-trib
    Sep 03, 2015 @ 20:55
    James Jackson-South
    100

    Just a heads up, the next release will have BoxPad. :)

  • Tom Steer 161 posts 596 karma points
    Sep 04, 2015 @ 13:27
    Tom Steer
    0

    Awesome! Nice one James :)

Please Sign in or register to post replies

Write your reply to:

Draft