aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-07-29 19:17:02 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-07-29 19:17:02 +0200
commiteb9fca3d9a52beec34d514173a718c9333abcfb3 (patch)
treec1e1b5f6d6404ad7f2d5a0139fa93c2091150fcf
parentb795e4348f0e27aa88012c4daa87b2a320ed7e02 (diff)
Add image processing script
-rwxr-xr-xprocess-img36
1 files changed, 36 insertions, 0 deletions
diff --git a/process-img b/process-img
new file mode 100755
index 0000000..ac25661
--- /dev/null
+++ b/process-img
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+usage()
+{
+ echo 'Usage: process-img [-f fuzz] file...' >&2
+ exit 1
+}
+
+while getopts 'f:' opt
+do
+ case "$opt" in
+ f)
+ fuzz="$optarg"
+ ;;
+ *)
+ usage
+ esac
+done
+
+shift $(($OPTIND - 1))
+[ "$#" -eq 0 ] && usage
+
+for img in "$@"
+do
+ (
+ read w h < <(identify -format "%w %h" "$img")
+ magick "$img" \
+ -alpha on -fuzz ${fuzz:-3%} -fill none \
+ -draw "color 0,0 floodfill" \
+ -draw "color 0,$((h-1)) floodfill" \
+ -draw "color $((w-1)),0 floodfill" \
+ -draw "color $((w-1)),$((h-1)) floodfill" \
+ "${img%.*}.avif"
+ ) &
+done
+wait \ No newline at end of file