scripts: convert: change convert command

This commit is contained in:
Mateusz Słodkowicz 2024-07-09 20:49:32 +02:00
parent 3ec62e702a
commit e0394f866c
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,9 @@
#/usr/bin/env bash
IFS=$'\n'
convert_cmd () {
if ! command -v convert &> /dev/null; then nix shell nixpkgs\#imagemagick -c convert "$@"; else convert "$@"; fi
}
change_to_webp() {
@ -7,7 +11,7 @@ change_to_webp() {
file="${f%.*}"
file_webp="${file}.webp"
echo "Trying to convert to $file_webp"
if convert "$f" "$file_webp"; then
if convert_cmd "$f" "$file_webp"; then
if touch -r "$f" "$file_webp"; then
rm "$f"
echo "Finished converting $f"