Quick Batch Image Resizer in VB.Net
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim OFD As New OpenFileDialog
If OFD.ShowDialog() = Windows.Forms.DialogResult.Cancel Then Exit Sub
For Each F As String In OFD.FileNames
Sub ResizeImage(ByVal sFile As String, ByVal percentResize As Double)
Dim sPath As String = sFile.Substring(0, sFile.LastIndexOf("\") + 1)
Dim sName As String = sFile.Substring(sFile.LastIndexOf("\") + 1)
Dim bm As New Bitmap(sFile)
Dim width As Integer = bm.Width * percentResize
Dim height As Integer = bm.Height * percentResize
Dim thumb As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(thumb)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
thumb.Save(sPath & sName.Substring(0, sName.LastIndexOf(".")) & " (2)" & sName.Substring(sName.LastIndexOf(".")), System.Drawing.Imaging.ImageFormat.Jpeg)