Skip to main content

Posts

Showing posts from August, 2013

Convert Image Formats

You could face situations like changing the format of the image file or reduce the file size by changing the formats. Here is the way to get it done in simple way. Function ConvertImage ( strFromFile , strToFile ) Dim oImage , oFileImage , oImageFormats , oFSO , strToExtn Set oFSO = CreateObject ( "Scripting.FileSystemObject" ) Set oImage = DotNetFactory . CreateInstance ( "System.Drawing.Image" ) Set oFileImage = oImage . FromFile ( strFromFile ) Set oImageFormats = DotNetFactory . CreateInstance ( "System.Drawing.Imaging.ImageFormat" , "System.Drawing" , Nothing ) strToExtn = oFSO . GetExtensionName ( strToFile ) Select Case UCase ( Trim ( strToExtn ) ) Case "JPEG" oFileImage . Save strToFile , oImageFormats . Jpeg Case "JPG" oFileImage . Save strToFile , oImageFormats . Jpeg Case "BMP" oFileImage . Save strToFile , oImageFormats . Bmp Case &quo