![]() ![]() It might be better to scale the main image (instead of scaling the embedded thumbnail) by calling the DrawImage method. If you request a large thumbnail image (for example, 300 x 300) from an Image that has an embedded thumbnail, there could be a noticeable loss of quality in the thumbnail image. The GetThumbnailImage method works well when the requested thumbnail image has a size of about 120 x 120 pixels. If the Image does not contain an embedded thumbnail image, this method creates a thumbnail image by scaling the main image. If the Image contains an embedded thumbnail image, this method retrieves the embedded thumbnail and scales it to the requested size. It is directly copy-pasted from MSDN library: Thumbnail.Save(toStream, image.RawFormat) Īwful, isn’t it? Now I tell you a little secret. Var thumbnail = image.GetThumbnailImage(newWidth, newHeight, abort, IntPtr.Zero) GetThumbnailImageAbort(ThumbnailCallback) Var newHeight = ( int )(image.Height * scaleFactor) Var newWidth = ( int )(image.Width * scaleFactor) public void ResizeImage( double scaleFactor, Stream fromStream, Stream toStream) Image.GetThumbnailImageĪs a first thing let’s use Image.GetThumbnailImage to get new version of original image that is four times smaller (512×384). This file contains thumbnail image and let’s see how previously pointed example fails. Be aware – size this file is about 1.6MB.Ĭlick on the image to see it in original size. I am on this photo too (guess which one). Our original image here is taken during Wacken Open Air 2005. This causes hard loss of quality and resized image look awful. It takes small thumbnail image and resizes it larger. If you take image with high resolution and resize it to 50% then using Image.GetThumbnailImage method may produce the result we expect. These thumbnails are embedded in original image and are usually small by their dimensions. One those functionalities is generating thumbnails of images. They can do many tricks we cannot even imagine if we are dumb users. In this post I will show you how to resize images without negative side effects.Ĭameras today are powerful tools. You can easily create crappy images if you follow the code examples in previously pointed article. ![]() There are many people out there who mistakenly think that Image.GetThumbnailImage is best choice for image resizing. ASP.NET provides us with System.Drawing namespace where we can find classes we can use to manipulate with images. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |