Last post Jan 21, 2010 12:07 AM by vipindas
Jan 19, 2010 12:48 AM|bluelinenetworks|LINK
I have a website that allows images for an item to be uploaded, pretty typical...
The users aren't good with resizing before upload, also typical...
Some photos are portrait (400x300) and some are landscape (300x400)
When I display them currently, my asp:image controls make them all display as sat 100x75 with a java script function to display them in a main image onmouseover at the 400x300 size.
Does anyone have advice on how to make them display with the correct orientation and also be able to do a mouseover and have it maintain the proper aspect ratio?
Jan 19, 2010 04:33 AM|chintanpshah|LINK
If you want to disaply them with correct sizes, you need to restrict user to upload images of specific size (400 x 300) only.
You also need to same original (big) and small version to show at default and mouse over positions.
Jan 19, 2010 12:04 PM|bluelinenetworks|LINK
So, no way to handle if there are pictures oriented vertically?
Jan 20, 2010 12:02 AM|chintanpshah|LINK
Its possible. But, picture quality will not be as good.
Jan 21, 2010 12:07 AM|vipindas|LINK
Try this. I think this will help u
public void ResizeStream(int imageSize, Stream filePath, string outputPath)
var image = Image.FromStream(filePath);
int thumbnailSize = imageSize;
int newWidth, newHeight;
if (image.Width > image.Height)
newWidth = thumbnailSize;
newHeight = image.Height * thumbnailSize / image.Width;
newWidth = image.Width * thumbnailSize / image.Height;
newHeight = thumbnailSize;
var thumbnailBitmap = new Bitmap(newWidth, newHeight);
var thumbnailGraph = Graphics.FromImage(thumbnailBitmap);
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);