public static Bitmap getThumbnail(string path, int width = 64, int height = 64) { switch (Path.GetExtension(path).ToLower()) { case ".tga": TGA tga = new TGA(path); Bitmap rawThumbnail = tga.GetThumbnail(); Bitmap thumbnail = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(thumbnail)) { g.DrawImage(rawThumbnail, 0, 0, width, height); return(thumbnail); } case ".webp": using (WebP webp = new WebP()) { return(webp.LoadThumbnail(path, width, height)); } case ".emf": using (Metafile source = new Metafile(path)) { Bitmap target = new Bitmap(width, height); using (var g = Graphics.FromImage(target)) { g.Clear(Color.White); g.DrawImage(source, 0, 0, width, height); return(target); } } default: Image src = Image.FromFile(path); return((Bitmap)src.GetThumbnailImage(width, height, () => false, IntPtr.Zero)); } }