Description
Determine the type of an image by reading the first bytes.
Description
A package used to determine the type of an image according to its first bytes based on the Python library imghdr.
Most simplest usage is getting the type of a file:
>>>
import Codec.ImageType
>>>
getFileType "/tmp/mystery_file"
Just "webp"
Or to test for a specific extension:
>>>
isPgm "/tmp/file.pgm"
True
>>>
import qualified Data.ByteString as B
>>>
testPgm <$> B.readFile "/tmp/file.pgm"
Just "pgm"
Or to filter files by extension:
>>>
import Codec.ImageType
>>>
import Control.Monad
>>>
import System.Directory
>>>
>>>
getDirectoryContents "." >>= filterM doesFileExist >>= filterM isJpeg
["file2.jpeg","file1.jpeg"]
Supports the following extensions: JPEG
, PNG
, GIF
, TIFF
, RGB
, PBM
, PGM
, PPM
, RAST
, XBM
, BMP
, WebP
, EXR
.