add compress image function
This commit is contained in:
parent
262a434bd4
commit
50459f199d
1 changed files with 12 additions and 0 deletions
12
flake.nix
12
flake.nix
|
|
@ -9,12 +9,24 @@
|
|||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
zola
|
||||
imagemagick
|
||||
(writeShellScriptBin "serve" ''
|
||||
zola serve --open
|
||||
'')
|
||||
(writeShellScriptBin "build" ''
|
||||
zola build
|
||||
'')
|
||||
(writeShellScriptBin "compress-images" ''
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: compress-images <folder>"
|
||||
exit 1
|
||||
fi
|
||||
find "$1" -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' \) | while read -r img; do
|
||||
outfile="''${img%.*}.webp"
|
||||
${imagemagick}/bin/magick "$img" -resize '1800>' -quality 82 "$outfile"
|
||||
echo "Converted: $img -> $outfile"
|
||||
done
|
||||
'')
|
||||
];
|
||||
shellHook = ''
|
||||
echo "Zola blog development environment"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue