Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script for converting images to AVIF format
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/zsh | ||
# | ||
# Given an image path/to/foo.jpg, converts it to an avif file named | ||
# path/to/foo.avif, maintaining the original file. | ||
# | ||
# This is necessary because the avifenc tool requires you to specify an | ||
# input file and an output file, but I almost always want to just use | ||
# the exact same filename and generate an avif alongside the original. | ||
# | ||
# Author: Rob Miller <r@robm.me.uk> | ||
|
||
set -eu -o pipefail | ||
|
||
IF="$1" | ||
OF="${1:r}.avif" | ||
|
||
if [ ! -f "$IF" ]; then | ||
echo "File $IF not found" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "Converting $IF to $OF" | ||
avifenc "$IF" "$OF" |