API
Version 7.x > API > Question about ImageHelper View modes: 
User avatar
Member
Member
cianmoloney05-gmail - 11/17/2013 5:17:58 PM
   
Question about ImageHelper
Hi all,

I'm using the ImageHelper to resize an attachment before publishing it to my CDN.

Say I have an image 800px x 500px that I want to re-size to 200px x 100px.. I use the Kentico attachment GUID to get the AttachmentInfo, and then ImageHelper to resize the image. However it doesn't work as expected, and will save the image to a size of 200px x 200px.

For example, if I have the correct values for width (200) and height (100)
AttachmentInfo ai = AttachmentInfoProvider.GetAttachmentInfo(attachmentGuid, CMSContext.CurrentSite.SiteName);

byte[] resizedImage = ImageHelper.GetResizedImageData(ai.AttachmentBinary, ai.AttachmentExtension, width, height, width);

Any ideas?

Thanks

User avatar
Member
Member
cianmoloney05-gmail - 11/17/2013 7:17:41 PM
   
RE:Question about ImageHelper
I've just found that feeding the GetResizedImageData with a maxSideSize of 0 (zero) will resize it to the specified width and height..

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 11/18/2013 5:00:12 AM
   
RE:Question about ImageHelper
Hello,

Yes, there are more variations of the method GetResizedImageData, for more details I would recommend you also to download the API Reference where you can find all parameters described. However, I'm glad that you have already found the right combination, great!

Best regards,
Martin Danko