Skip to content

Commit

Permalink
Script for converting images to AVIF format
Browse files Browse the repository at this point in the history
  • Loading branch information
robmiller committed Oct 19, 2023
1 parent 50d956c commit e5d2a7d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bin/img2avif
@@ -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"

0 comments on commit e5d2a7d

Please sign in to comment.