-- 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:
--   
--   <ul>
--   <li>File sizes are constrained and checked.</li>
--   <li>Image sizes are constrained and checked before the images are
--   loaded into memory. Uses <tt>imagesize-conduit</tt> by Michael
--   Snoyman.</li>
--   <li>Optionally, the original image is reencoded before being
--   saved.</li>
--   <li>The images are processed using the <a>GD library</a>, which is
--   heavily battle-tested and <a>audited by many pairs of
--   eyeballs</a>.</li>
--   </ul>
--   
--   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.5

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, MonadThrow n) => Consumer ByteString m (n (Size, FileFormat))

module Graphics.ThumbnailPlus

-- | Process an image and generate thumbnails for it according to the given
--   <a>Configuration</a>.
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:
--   <a>SameFileFormat</a>.
[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 <a>FileFormat</a> 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:
--   <a>getTemporaryDirectory</a>.
[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.,
--   <a>reencodeOriginal</a>).
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 <a>createThumbnails</a>.
data CreatedThumbnails

-- | File size exceeded <a>maxFileSize</a>.
FileSizeTooLarge :: !Integer -> CreatedThumbnails

-- | Image size exceeded <a>maxImageSize</a>.
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 <a>reencodeOriginal</a> was
--   not <a>Never</a>, 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 <a>Thumbnail</a> will
--   actually have the size of the original image.
data Thumbnail
Thumbnail :: !FilePath -> !Size -> !FileFormat -> !(NoShow ReleaseKey) -> Thumbnail

-- | The <a>FilePath</a> 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 <a>runResourceT</a>
--   finishes).
[thumbReleaseKey] :: Thumbnail -> !(NoShow ReleaseKey)

-- | Hack to allow me to derive <a>Show</a> for data types with fields that
--   don't have <a>Show</a> instances.
newtype NoShow a
NoShow :: a -> NoShow a
instance GHC.Show.Show Graphics.ThumbnailPlus.CreatedThumbnails
instance GHC.Classes.Eq Graphics.ThumbnailPlus.CreatedThumbnails
instance GHC.Show.Show Graphics.ThumbnailPlus.Thumbnail
instance GHC.Classes.Eq Graphics.ThumbnailPlus.Thumbnail
instance GHC.Show.Show Graphics.ThumbnailPlus.ReencodeOriginal
instance GHC.Classes.Ord Graphics.ThumbnailPlus.ReencodeOriginal
instance GHC.Classes.Eq Graphics.ThumbnailPlus.ReencodeOriginal
instance Data.Default.Class.Default Graphics.ThumbnailPlus.Configuration
instance Data.Typeable.Internal.Typeable a => GHC.Show.Show (Graphics.ThumbnailPlus.NoShow a)
instance GHC.Classes.Eq (Graphics.ThumbnailPlus.NoShow a)
