generate jxl from png,jpg,gif

This commit is contained in:
rhiannon morris 2023-01-15 21:39:03 +01:00
parent 76ccbe3c7d
commit 0f20753808
3 changed files with 26 additions and 8 deletions

View File

@ -66,6 +66,11 @@ $(TMPDIR)/%_big.jpg: $(DATADIR)/%.jpg
$(call resize,$(BIG),$(BIG),>)
%.jxl: %.png ; $(call cjxl,-e 9)
%.jxl: %.jpg ; $(call cjxl,-e 9)
%.jxl: %.gif ; $(call cjxl)
$(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
echo "[make-pages]"
mkdir -p $(dir $@)
@ -133,6 +138,14 @@ mkdir -p "$(dir $@)"
convert -resize "$(1)x$(2)$(3)" $(4) "$^" "$@"
endef
# args:
# 1. extra flags
define cjxl
echo "[cjxl] "$@
mkdir -p "$(dir $@)"
cjxl -d 1 "$^" "$@" $(1) 2>/dev/null
endef
# no args
define depend-gallery
echo "[deps] "$@

View File

@ -29,17 +29,22 @@ dependSingle' yamlDir indexFile info prefix build nsfw =
where
images = #all if nsfw then #images info else #sfwImages info
paths = map #path images
paths = map #path images
thumb = thumbFile $ thumbnail info
jxls fs = [base <.> "jxl" | f <- fs,
let (base, ext) = splitExtension f,
ext `elem` imgTypes]
imgTypes = words ".png .jpg .gif"
imgFiles0 = thumb : map pageFile paths ++ map bigFile paths
imgFiles = imgFiles0 ++ jxls imgFiles0
dls = mapMaybe #download images
extras = #extras info
dir = build </> prefix </> yamlDir
page = dir </> "index.html"
deps = unwords $ map (dir </>) $
thumbFile (thumbnail info) :
map pageFile paths ++
map bigFile paths ++
dls ++ extras
deps = unwords $ map (dir </>) $ imgFiles ++ dls ++ extras
dependGallery :: GalleryInfo
-> FilePath -- ^ index file

View File

@ -33,7 +33,7 @@ import Data.Text (Text)
import qualified Data.Text as Text
import Data.YAML (FromYAML (..), (.:), (.:?), (.!=))
import qualified Data.YAML as YAML
import System.FilePath ((</>), takeBaseName, takeExtension, splitExtension)
import System.FilePath ((</>), takeBaseName, takeExtension, splitExtensions)
import Data.Bifunctor (second)
@ -244,7 +244,7 @@ bigFile f
addSuffix :: String -> FilePath -> FilePath
addSuffix suf path =
let (pre, ext) = splitExtension path in
let (pre, ext) = splitExtensions path in
pre ++ suf ++ ext