aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Processors.hs
diff options
context:
space:
mode:
authorpacien2020-01-05 16:24:02 +0100
committerpacien2020-01-05 16:24:02 +0100
commit9dd271504160b624284dbc438cdc867b6ca0d0e7 (patch)
tree8701aa1897e664aab1f80a7952dbdc5c0c27624c /compiler/src/Processors.hs
parentabdf82bbfde843a87bd00746f52dafdd28f3f60b (diff)
downloadldgallery-9dd271504160b624284dbc438cdc867b6ca0d0e7.tar.gz
compiler: enable warnings and fix them
GitHub: fixes #9
Diffstat (limited to 'compiler/src/Processors.hs')
-rw-r--r--compiler/src/Processors.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs
index 2525af4..6ee8c78 100644
--- a/compiler/src/Processors.hs
+++ b/compiler/src/Processors.hs
@@ -32,7 +32,7 @@ module Processors
32 ) where 32 ) where
33 33
34 34
35import Control.Exception (Exception, throwIO) 35import Control.Exception (Exception, PatternMatchFail(..), throw, throwIO)
36import Data.Function ((&)) 36import Data.Function ((&))
37import Data.Ratio ((%)) 37import Data.Ratio ((%))
38import Data.Char (toLower) 38import Data.Char (toLower)
@@ -90,12 +90,13 @@ resizeStaticImageUpTo Jpg = resizeStaticGeneric readJpeg (saveJpgImage 80)
90resizeStaticImageUpTo Png = resizeStaticGeneric readPng savePngImage 90resizeStaticImageUpTo Png = resizeStaticGeneric readPng savePngImage
91resizeStaticImageUpTo Tiff = resizeStaticGeneric readTiff saveTiffImage 91resizeStaticImageUpTo Tiff = resizeStaticGeneric readTiff saveTiffImage
92resizeStaticImageUpTo Hdr = resizeStaticGeneric readHDR saveRadianceImage 92resizeStaticImageUpTo Hdr = resizeStaticGeneric readHDR saveRadianceImage
93resizeStaticImageUpTo Gif = resizeStaticGeneric readGif writeGifImage 93resizeStaticImageUpTo Gif = resizeStaticGeneric readGif saveGifImage'
94 where 94 where
95 writeGifImage :: StaticImageWriter 95 saveGifImage' :: StaticImageWriter
96 writeGifImage outputPath image = 96 saveGifImage' outputPath image =
97 saveGifImage outputPath image 97 saveGifImage outputPath image
98 & either (throwIO . ProcessingException outputPath) id 98 & either (throwIO . ProcessingException outputPath) id
99resizeStaticImageUpTo _ = throw $ PatternMatchFail "Unhandled format"
99 100
100 101
101type StaticImageReader = FilePath -> IO (Either String DynamicImage) 102type StaticImageReader = FilePath -> IO (Either String DynamicImage)
@@ -166,14 +167,14 @@ type ItemFileProcessor =
166 -> ItemProcessor 167 -> ItemProcessor
167 168
168itemFileProcessor :: Maybe Resolution -> Cache -> ItemFileProcessor 169itemFileProcessor :: Maybe Resolution -> Cache -> ItemFileProcessor
169itemFileProcessor maxRes cached inputBase outputBase resClass inputRes = 170itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes =
170 cached processor inPath outPath 171 cached processor inPath outPath
171 >> return (relOutPath, props) 172 >> return (relOutPath, props)
172 where 173 where
173 relOutPath = resClass /> inputRes 174 relOutPath = resClass /> inputRes
174 inPath = localPath $ inputBase /> inputRes 175 inPath = localPath $ inputBase /> inputRes
175 outPath = localPath $ outputBase /> relOutPath 176 outPath = localPath $ outputBase /> relOutPath
176 (processor, props) = formatProcessor maxRes $ formatFromPath inputRes 177 (processor, props) = formatProcessor maxResolution $ formatFromPath inputRes
177 178
178 formatProcessor :: Maybe Resolution -> Format -> (FileProcessor, GalleryItemProps) 179 formatProcessor :: Maybe Resolution -> Format -> (FileProcessor, GalleryItemProps)
179 formatProcessor Nothing _ = (copyFileProcessor, Other) 180 formatProcessor Nothing _ = (copyFileProcessor, Other)
@@ -203,8 +204,8 @@ thumbnailFileProcessor maxRes cached inputBase outputBase resClass inputRes =
203 204
204 process :: Maybe FileProcessor -> IO (Maybe Path) 205 process :: Maybe FileProcessor -> IO (Maybe Path)
205 process Nothing = return Nothing 206 process Nothing = return Nothing
206 process (Just processor) = 207 process (Just proc) =
207 processor inPath outPath 208 proc inPath outPath
208 >> return (Just relOutPath) 209 >> return (Just relOutPath)
209 210
210 processor :: Format -> Maybe FileProcessor 211 processor :: Format -> Maybe FileProcessor