Introduction
This application gets the source folder of images/photos in JPEG format and resizes them into a specific size and saves them into a destination directory.
The user can check crop setting for cropping images before resizing them.
Using the Code
Public Function ResizePicture(ByVal sourceImage As Bitmap, _
ByVal newSize As Size) As Bitmap
Dim Result_image As New Bitmap(sourceImage, newSize.Width, newSize.Height)
Dim Gr As Graphics
Gr = Graphics.FromImage(Result_image)
Gr.DrawImage(Result_image, 0, 0, newSize.Width, newSize.Height)
Gr.Save()
Return Result_image
End Function
Public Function CropBitmap(ByVal inputBmp As Bitmap, _
ByVal cropRectangle As Rectangle) As Bitmap
Dim newBmp As New Bitmap(cropRectangle.Width, _
cropRectangle.Height, _
System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim newBmpGraphics As Graphics = Graphics.FromImage(newBmp)
newBmpGraphics.DrawImage(inputBmp, _
New Rectangle(0, 0, cropRectangle.Width, cropRectangle.Height), _
cropRectangle, _
GraphicsUnit.Pixel)
newBmpGraphics.Dispose()
Return newBmp
End Function
I wrote this application in about 30 minutes. This program is useful for batch resizing for a large number of photos.
History
- 21st February, 2008: Initial post
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.