Private/Get-ImageFormat.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using namespace System.Drawing

function Get-ImageFormat {
    [CmdletBinding()]
    [OutputType([Imaging.ImageFormat])]
    param(
        [Parameter(Mandatory, ValueFromPipeline, Position = 0)]
        [ValidateSet("Bmp", "Emf", "Exif", "Gif", "Jpeg", "Png", "Tiff", "Wmf")]
        [string]
        $Format
    )
    process {
        switch ($Format) {
            "Bmp"  { [Imaging.ImageFormat]::Bmp  }
            "Emf"  { [Imaging.ImageFormat]::Emf  }
            "Exif" { [Imaging.ImageFormat]::Exif }
            "Gif"  { [Imaging.ImageFormat]::Gif  }
            "Jpeg" { [Imaging.ImageFormat]::Jpeg }
            "Png"  { [Imaging.ImageFormat]::Png  }
            "Tiff" { [Imaging.ImageFormat]::Tiff }
            "Wmf"  { [Imaging.ImageFormat]::Wmf  }
        }
    }
}