From 5a7f6c7eb9e5304f23230f2c024af419f7d92637 Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 20 Aug 2015 01:42:17 +0200 Subject: [PATCH] proper handling of gif and svg --- Handler/Upload.hs | 4 +++- Helper.hs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Handler/Upload.hs b/Handler/Upload.hs index 9bdec6e..45b222e 100644 --- a/Handler/Upload.hs +++ b/Handler/Upload.hs @@ -133,12 +133,14 @@ generateThumb path userId albumId = do FP. newName (iWidth, tWidth) <- liftIO $ withMagickWandGenesis $ do (_ , w) <- magickWand - setImageFormat w "jpeg" + p <- pixelWand readImage w (decodeString path) w1 <- getImageWidth w h1 <- getImageHeight w h2 <- return 230 w2 <- return $ floor (((fromIntegral w1) / (fromIntegral h1)) * (fromIntegral h2) :: Double) + setImageAlphaChannel w deactivateAlphaChannel + setImageFormat w "jpeg" resizeImage w w2 h2 lanczosFilter 1 setImageCompressionQuality w 95 writeImage w (Just (decodeString newPath)) diff --git a/Helper.hs b/Helper.hs index dc350e1..f5ffea6 100644 --- a/Helper.hs +++ b/Helper.hs @@ -148,7 +148,7 @@ reverseLookup s ((x, y):zs) | otherwise = Nothing acceptedTypes :: [T.Text] -acceptedTypes = ["image/jpeg", "image/jpg", "image/png", "image/x-ms-bmp", "image/x-bmp", "image/bmp", "image/tiff", "image/tiff-fx"] +acceptedTypes = ["image/jpeg", "image/jpg", "image/png", "image/x-ms-bmp", "image/x-bmp", "image/bmp", "image/tiff", "image/tiff-fx", "image/svg+xml", "image/gif"] iso8601 :: FormatTime t => t -> String iso8601 time =