devxlogo

GetImageFormat – Retrieve the format of the input image, according on its extension

GetImageFormat – Retrieve the format of the input image, according on its extension

' Return the format of the input image, according on its extension' Example: Dim imgFormat As System.Drawing.imaging.ImageFormat = GetImageFormat' ("D:sample.gif")Function GetImageFormat(ByVal imgPath As String) As _    System.Drawing.imaging.ImageFormat    imgPath = imgPath.ToLower()    If imgPath.EndsWith(".bmp") Then        Return System.Drawing.Imaging.ImageFormat.Bmp    ElseIf imgPath.EndsWith(".emf") Then        Return System.Drawing.Imaging.ImageFormat.Emf    ElseIf imgPath.EndsWith(".gif") Then        Return System.Drawing.Imaging.ImageFormat.Gif    ElseIf imgPath.EndsWith(".ico") Then        Return System.Drawing.Imaging.ImageFormat.Icon    ElseIf imgPath.EndsWith(".jpg") OrElse imgPath.EndsWith(".jpeg") Then        Return System.Drawing.Imaging.ImageFormat.Jpeg    ElseIf imgPath.EndsWith(".png") Then        Return System.Drawing.Imaging.ImageFormat.Png    ElseIf imgPath.EndsWith(".tif") OrElse imgPath.EndsWith(".tiff") Then        Return System.Drawing.Imaging.ImageFormat.Tiff    ElseIf imgPath.EndsWith(".wmf") Then        Return System.Drawing.Imaging.ImageFormat.Wmf    Else        Return System.Drawing.Imaging.ImageFormat.Gif    End IfEnd Function

See also  Is Machine Learning Automating Creativity in Graphic Design?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist