Click here to Skip to main content
16,018,973 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
C#
private void GenerateThumbnails(double scaleFactor, Stream sourcePath,string targetPath)
{
       using (var image = System.Drawing.Image.FromStream(sourcePath))
        {
           // can given width of image as we want
           var newWidth = (int)(image.Width * scaleFactor);
           // can given height of image as we want
           var newHeight = (int)(image.Height * scaleFactor);
           var thumbnailImg = new Bitmap(newWidth, newHeight);
           var thumbGraph = Graphics.FromImage(thumbnailImg);
           thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
           thumbGraph.SmoothingMode = SmoothingMode.HighQuality;
           thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
           var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
           thumbGraph.DrawImage(image, imageRectangle);
           thumbnailImg.Save(targetPath, image.RawFormat);
       }
}

it work on localy but after upload on web server it throw an exception a "generic error occured in gdi+"
Posted
Updated 18-Jun-12 20:18pm
v2
Comments
Sergey Alexandrovich Kryukov 19-Jun-12 2:25am    
In what line of code?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900