Safe Haskell | None |
---|---|
Language | Haskell2010 |
Uses the DevIL C library to read and write images from and to files.
Note: As the underlier DevIL library is *not* tread-safe, there is a global lock which will prevent two load/save calls to be performed at the same time.
- data ImageType
- data StorageImage
- data StorageError
- load :: Maybe ImageType -> FilePath -> IO (Either StorageError StorageImage)
- loadBS :: Maybe ImageType -> ByteString -> IO (Either StorageError StorageImage)
- save :: Convertible i StorageImage => FilePath -> i -> IO (Maybe StorageError)
Documentation
data StorageImage Source
data StorageError Source
FailedToInit | Failed to initialise the library. |
FailedToOpenFile | Failed to open the given file. |
InvalidType | The file could not be loaded based on extension or header. |
OutOfMemory | Could not allocate memory for the new image data. |
FailedToLoad | Failed to load the image, invalid format. |
FailedToHaskell | Failed to convert the loaded image to its Haskell representation. |
FailedToDevil | Failed to write the image content through the inner DevIL library. |
FailedToSave | Could not open the file for writing. |
UnknownError (Maybe String) |
load :: Maybe ImageType -> FilePath -> IO (Either StorageError StorageImage) Source
Reads an image into a manifest vector from a file.
If no image type is given, type will be determined automatically.
loadBS :: Maybe ImageType -> ByteString -> IO (Either StorageError StorageImage) Source
Reads an image into a manifest vector from a strict ByteString
.
If no image type is given, type will be determined automatically. TIFF images are not supported.
save :: Convertible i StorageImage => FilePath -> i -> IO (Maybe StorageError) Source
Saves the image to the given file.
Note: The image type is determined by the filename extension. Will fail if the file already exists.