add two image convert functions

This commit is contained in:
Yan Lin 2026-01-31 07:37:13 +01:00
parent 338910468a
commit 0eaf3cb322

View file

@ -8,6 +8,7 @@
flac
unzip
p7zip
imagemagick
];
programs.zsh.initContent = ''
@ -54,6 +55,24 @@
shnsplit -f "$cue" -t "%n - %t" -o "$fmt" -d ./tracks "$audio"
}
function image2webp() {
local dir="''${1:-.}"
find "$dir" -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' \) | while read -r img; do
outfile="''${img%.*}.webp"
${pkgs.imagemagick}/bin/magick "$img" -resize '1800>' -quality 82 "$outfile"
echo "Converted: $img -> $outfile"
done
}
function webp2png() {
local dir="''${1:-.}"
find "$dir" -type f -iname '*.webp' | while read -r img; do
outfile="''${img%.*}.png"
${pkgs.imagemagick}/bin/magick "$img" "$outfile"
echo "Converted: $img -> $outfile"
done
}
function camera-copy() {
local delete_source=0
if [[ "$1" == "-d" || "$1" == "--delete" ]]; then