static void ScaleImage(ImageInfo info) { int startTick = Environment.TickCount; var orig = info.OriginalImage; info.OriginalImage = null; const int scale = 200; var isLandscape = (orig.Width > orig.Height); var newWidth = isLandscape ? scale : scale * orig.Width / orig.Height; var newHeight = !isLandscape ? scale : scale * orig.Height / orig.Width; Bitmap bitmap = new Bitmap(orig, newWidth, newHeight); try { Bitmap bitmap2 = bitmap.AddBorder(15); try { bitmap2.Tag = orig.Tag; info.ThumbnailImage = bitmap2; info.PhaseStartTick[1] = startTick - info.ClockOffset; bitmap2 = null; } finally { if (bitmap2 != null) { bitmap2.Dispose(); } } } finally { bitmap.Dispose(); orig.Dispose(); } info.PhaseEndTick[1] = Environment.TickCount - info.ClockOffset; }