source $HOME/bin/build-template
DEPENDENCIES=(
"convert,https://imagemagick.org/"
)
execute() {
local -r DIR_SRC="$HOME/dev/writing/impacts/renders/output"
local -r DIR_DST="images"
local -r WIDTH_X=300
$log "Downscale renders to ${WIDTH_X}px"
for i in $(find ${DIR_SRC} -type f -name "page-??.png"); do
file_src="$(basename ${i})"
file_dst="$(basename ${file_src} .png).jpg"
path_dst="${DIR_DST}/${file_dst}"
$log "Processing ${file_src} to ${path_dst}"
convert "$i" \
\( +clone -background "#202020" -shadow 80x3+10+10 -channel RGBA -blur 0x20 \) \
+swap -background transparent -layers merge -dither None -depth 8 \
-resize "${WIDTH_X}x" -background "#fefefe" \
-flatten +repage -trim - | \
pngtopnm - | \
jpeg-recompress \
--quiet --strip --ppm --quality "veryhigh" \
--accurate --method ssim - \
"${path_dst}"
done
return 1
}
main "$@"