New features
Version 3.x > New features > GetFile/Thumbnail maximum size re-sizing (non-square) View modes: 
User avatar
Member
Member
Mufasa - 10/22/2008 6:22:54 PM
   
GetFile/Thumbnail maximum size re-sizing (non-square)
The getfile.aspx usage allows for a "maxsidesize" to limit an image so that it will be no bigger the X number of pixels in a square. But what if you want to limit the size to fit within a rectangular area?

Here's what you could add when checking the image size in CMS.GlobalHelper.ImageHelper.EnsureImageDimensions if you added a maxWidth and maxHeight parameter:

// check width
if (maxWidth > 0 && maxWidth < imageWidth)
{
newWidth = maxWidth;
aspectRatio = Convert.ToDouble(newWidth) / Convert.ToDouble(imageWidth);
newHeight = Convert.ToInt32((double)(imageHeight * aspectRatio));
}

// check height
if (maxHeight > 0 && maxHeight < newHeight)
{
aspectRatio = Convert.ToDouble(maxHeight) / Convert.ToDouble(newHeight);
newWidth = Convert.ToInt32((double)(newWidth * aspectRatio));
newHeight = maxHeight;
}


Mufasa

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 10/23/2008 7:46:32 AM
   
RE:GetFile/Thumbnail maximum size re-sizing (non-square)
Hello,

thank you for your contribution. It will be certainly helpful for other users!

Best regards,
Helena Grulichova