-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Generate thumbnails easily and safely.
--
-- This package provides every tool you need to easily and safely
-- generate thumbnails for JPG, GIF and PNG images.
--
-- By safely, we mean that this package should be able to handle images
-- uploaded to a public web server without any known vulnerabilities:
--
--
-- - File sizes are constrained and checked.
-- - Image sizes are constrained and checked before the images are
-- loaded into memory. Uses imagesize-conduit by Michael
-- Snoyman.
-- - Optionally, the original image is reencoded before being
-- saved.
-- - The images are processed using the GD library, which is
-- heavily battle-tested and audited by many pairs of
-- eyeballs.
--
--
-- Please report any vulnerabilities you may find, we take strive to make
-- this library suitable for processing arbitrary images.
@package thumbnail-plus
@version 1.0.4
module Graphics.ThumbnailPlus.ImageSize
data Size :: *
Size :: Int -> Int -> Size
width :: Size -> Int
height :: Size -> Int
data FileFormat :: *
GIF :: FileFormat
PNG :: FileFormat
JPG :: FileFormat
-- | Find out the size of an image. Also returns the file format that
-- parsed correctly. Note that this function does not verify that the
-- file is indeed in the format that it returns, since it looks only at a
-- small part of the header.
sinkImageInfo :: Monad m => Consumer ByteString m (Maybe (Size, FileFormat))
module Graphics.ThumbnailPlus
-- | Process an image and generate thumbnails for it according to the given
-- Configuration.
createThumbnails :: MonadResource m => Configuration -> FilePath -> m CreatedThumbnails
-- | Configuration used when
data Configuration
Configuration :: !Integer -> !Size -> !ReencodeOriginal -> [(Size, Maybe FileFormat)] -> IO FilePath -> Configuration
-- | Maximum file size in bytes. Files larger than this limit are rejected.
-- Default: 5 MiB.
maxFileSize :: Configuration -> !Integer
-- | Maximum image size in pixels. Images which exceed this limit in any
-- dimension are rejected. Default: 3000x3000px.
maxImageSize :: Configuration -> !Size
-- | Whether the original image should be reencoded. Default:
-- SameFileFormat.
reencodeOriginal :: Configuration -> !ReencodeOriginal
-- | The sizes of the thumbnails that should be created. Thumbnails
-- preserve the aspect ratio and have at least one dimension equal to the
-- given requested size. Sizes larger than the original image will be
-- disregarded. If a FileFormat is not provided, the same file
-- format as the original image is reused. Default: 512x512, 64x64.
thumbnailSizes :: Configuration -> [(Size, Maybe FileFormat)]
-- | Temporary directory where files should be saved. Default:
-- getTemporaryDirectory.
temporaryDirectory :: Configuration -> IO FilePath
data Size :: *
Size :: Int -> Int -> Size
width :: Size -> Int
height :: Size -> Int
-- | Whether the original image should be reencoded or not (cf.,
-- reencodeOriginal).
data ReencodeOriginal
-- | Do not reencode the original image.
Never :: ReencodeOriginal
-- | Reencode the original using the same file format.
SameFileFormat :: ReencodeOriginal
-- | Reencode the original using the given file format.
NewFileFormat :: !FileFormat -> ReencodeOriginal
data FileFormat :: *
GIF :: FileFormat
PNG :: FileFormat
JPG :: FileFormat
-- | Return value of createThumbnails.
data CreatedThumbnails
-- | File size exceeded maxFileSize.
FileSizeTooLarge :: !Integer -> CreatedThumbnails
-- | Image size exceeded maxImageSize.
ImageSizeTooLarge :: !Size -> CreatedThumbnails
-- | Could not parse size information for the image. Remember that we
-- understand JPGs, PNGs and GIFs only.
ImageFormatUnrecognized :: CreatedThumbnails
-- | Thumbnails were created successfully. If reencodeOriginal was
-- not Never, then the first item of the list is going to be the
-- reencoded image.
CreatedThumbnails :: ![Thumbnail] -> !(NoShow ReleaseKey) -> CreatedThumbnails
-- | Information about a generated thumbnail. Note that if ask for the
-- original image to be reencoded, then the first Thumbnail will
-- actually have the size of the original image.
data Thumbnail
Thumbnail :: !FilePath -> !Size -> !FileFormat -> !(NoShow ReleaseKey) -> Thumbnail
-- | The FilePath where this thumbnail is stored.
thumbFp :: Thumbnail -> !FilePath
-- | Size of the thumbnail.
thumbSize :: Thumbnail -> !Size
thumbFormat :: Thumbnail -> !FileFormat
-- | Release key that may be used to clean up any resources used by this
-- thumbnail as soon as possible (i.e., before runResourceT
-- finishes).
thumbReleaseKey :: Thumbnail -> !(NoShow ReleaseKey)
-- | Hack to allow me to derive Show for data types with fields that
-- don't have Show instances.
newtype NoShow a
NoShow :: a -> NoShow a
instance Typeable ReencodeOriginal
instance Typeable Configuration
instance Typeable Thumbnail
instance Typeable CreatedThumbnails
instance Eq ReencodeOriginal
instance Ord ReencodeOriginal
instance Show ReencodeOriginal
instance Eq Thumbnail
instance Show Thumbnail
instance Eq CreatedThumbnails
instance Show CreatedThumbnails
instance Eq (NoShow a)
instance Typeable a => Show (NoShow a)
instance Default Configuration