Rotate and/or Flip an Image from a File

This snippet gives the programmer the ability to Rotate and/or flip an Image from a file. The programmer can choose where to save the file, and it will overwrite the file if it exists.


''' <summary>
''' Rotates and/or flips an image from a file.
''' </summary>
''' <param name="imgPath">The path of the image you'd like to flip.</param>
''' <param name="savePath">The path of the flipped image you'd like to save to.</param>
''' <param name="rotFlipType">The RotateFlipType enum to flip or rotate the image.</param>
''' <param name="imgFormat">The format to save the file to.</param>
''' <remarks></remarks>

Public Sub rotFlipImageFromFile(ByRef imgPath As String, ByRef savePath As String, _
ByRef rotFlipType As RotateFlipType, ByRef imgFormat As System.Drawing.Imaging.ImageFormat)
    Dim img As System.Drawing.Image
    img = System.Drawing.Bitmap.FromFile(imgPath)
    ' We delete the file if it exists so it doesn't fail.
    If System.IO.File.Exists(savePath) Then System.IO.File.Delete(savePath)
    img.Save(savePath, imgFormat)
End Sub

' Example usage of the snippet:
rotFlipImageFromFile("c:\lol.gif", "c:\lol.gif", RotateFlipType.RotateNoneFlipXY, _

See Also

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License