diff options
| author | Miguel <m.i@gmx.at> | 2019-03-07 22:21:09 +0100 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2019-03-07 22:21:09 +0100 |
| commit | b74714630a07b05b696733bd533ad0d8569392e1 (patch) | |
| tree | ddcce40a14106b1aca0c4176b34c42b9235032b6 /src/WWWStaticusPlugins.hs | |
| parent | 4638487e5a44a5f291e0bc9cb15b20eb3b553399 (diff) | |
scaling images with image magick
Diffstat (limited to 'src/WWWStaticusPlugins.hs')
| -rw-r--r-- | src/WWWStaticusPlugins.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/WWWStaticusPlugins.hs b/src/WWWStaticusPlugins.hs index 668dfb6..043e40e 100644 --- a/src/WWWStaticusPlugins.hs +++ b/src/WWWStaticusPlugins.hs @@ -12,6 +12,7 @@ module WWWStaticusPlugins ) where import WWWStaticus +import System.Process import System.Directory as D import System.IO.Error import Data.Time.Clock as C @@ -65,7 +66,7 @@ staticusPluginsDefault::[StaticusPlugin] staticusPluginsDefault=[ staticusPluginInit ,staticusPluginTimestamp ,staticusPluginCfg - ,staticusPluginCopy [".jpg",".png",".zip",".css",".js",".ico",".mp4",".ogv",".hs",".glade",".cast"] + ,staticusPluginCopy [".jpg",".png",".zip",".css",".js",".ico",".mp4",".ogv",".hs",".glade",".cast",".pdf"] ,staticusPluginCards ,staticusDownloadEmbed ,staticusPluginPandoc @@ -129,9 +130,16 @@ staticusPluginCopy::[String]->StaticusPlugin staticusPluginCopy ext = StaticusPlugin "copy by extension" id runIO where runIO m = do let tst x=or $ map ($x) (map isSuffixOf ext) + let tst_img x=or $ map ($x) (map isSuffixOf [".jpg",".png"]) + let tst_vid x=or $ map ($x) (map isSuffixOf [".ogv",".ogg"]) dl <- filter tst <$> listDirectory (par "path" m) mapM_ (\x->copyFile (par "path" m++"/"++x) (par "outdir" m++"/"++x)) dl + mapM_ (\x->scaleFile (par "path" m++"/"++x) (par "outdir" m++"/"++x)) $ filter tst_img dl return m + where scaleFile fin fout = do let conv_cmd = "convert \""++fin++"\" -resize 640x640 \""++renameImg fout++"\"" + putStrLn conv_cmd + system conv_cmd + renameImg = uncurry (++) . first (("/"++).intercalate "/". init) . second (("/scale_"++).last) . dupe . splitOn "/" -- |extracts config lines (###>>>) from 'index.md' staticusPluginCfg::StaticusPlugin @@ -162,7 +170,6 @@ staticusPluginFill = StaticusPlugin "fill template" run return replace "###KEYWORDS###" (par' "###>>>KWD" m) $ (par "template.html" m))]) m t (a,b) = if a=="" then b else a - -- |write final index.html file staticusPluginWrite::StaticusPlugin |
