add git-annex-compute-imageconvert
authorJoey Hess <joeyh@joeyh.name>
Thu, 6 Mar 2025 18:47:22 +0000 (14:47 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 6 Mar 2025 18:47:22 +0000 (14:47 -0400)
COPYRIGHT
doc/special_remotes/compute.mdwn
doc/special_remotes/compute/git-annex-compute-imageconvert [new file with mode: 0755]

index 71f1d59aaa4058f8c0b894e0c0ea48758da74743..7dfe659c6abf397d48c49a780cff47c19b6d6aef 100644 (file)
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -14,6 +14,10 @@ Files: doc/special_remotes/external/*
 Copyright: © 2013 Joey Hess <id@joeyh.name>
 License: GPL-3+
 
+Files: doc/special_remotes/compute/git-annex-compute-imageconvert
+Copyright: © 2025 Joey Hess <id@joeyh.name>
+License: GPL-3+
+
 Files: doc/design/external_backend_protocol/git-annex-backend-XFOO
 Copyright: © 2020 Joey Hess <id@joeyh.name>
 License: GPL-3+
index 264cec825ae5a0c5168a40c17b34946f0ba9dcdc..36bda5a62b565dc65060ee35b615ebc5317eb4a3 100644 (file)
@@ -32,6 +32,9 @@ To write programs used by the compute special remote, see the
 [[design/compute_special_remote_interface]].
 
 Have you written a generally useful (and secure) compute program?
-List it here!
+List it here with an example!
 
-* ...
+* [[compute/git-annex-compute-imageconvert]] --
+  Uses imagemagick to convert between image formats
+
+  `git-annex addcomputed --to=imageconvert foo.jpeg foo.gif`
diff --git a/doc/special_remotes/compute/git-annex-compute-imageconvert b/doc/special_remotes/compute/git-annex-compute-imageconvert
new file mode 100755 (executable)
index 0000000..fb106e5
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+# git-annex compute special remote program that uses imagemagic's convert
+# to convert one type of image format into another. Eg, jpeg to gif.
+# 
+# Copyright 2025 Joey Hess; licenced under the GNU GPL version 3 or higher.
+set -e
+
+if [ -z "$1" ] || [ -z "$2" ]; then
+       echo "Specify the input image file, followed by the output image file." >&2
+       echo "Example: foo.jpg foo.gif" >&2
+       exit 1
+fi
+
+echo "INPUT $1"
+read input
+echo "OUTPUT $2"
+
+if [ -n "$input" ]; then
+       # Prefixing the filenames with "./" makes sure that they are processed
+       # as files, even if they look like dashed options.
+       mkdir -p "$(dirname "./$2")"
+       ln -s "$input" "./$1"
+       convert "./$1" "./$2"
+fi