From e55597aa6a3115b148685b56478b95a24acd8927 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 25 Nov 2024 16:55:31 +0100 Subject: fix(modules/lf/ctpv): Don't try to preview `.xcf` images --- modules/by-name/lf/lf/ctpv/default.nix | 8 ++++++++ modules/by-name/lf/lf/ctpv/prev/xcf.sh | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 modules/by-name/lf/lf/ctpv/prev/xcf.sh diff --git a/modules/by-name/lf/lf/ctpv/default.nix b/modules/by-name/lf/lf/ctpv/default.nix index b47e03bd..f61b65f1 100644 --- a/modules/by-name/lf/lf/ctpv/default.nix +++ b/modules/by-name/lf/lf/ctpv/default.nix @@ -163,6 +163,14 @@ in ]; }; + xcf = { + priority = 1; + mime_matches = ["image/x-xcf"]; + dependencies = [ + # pkgs.gimp + pkgs.exiftool + ]; + }; svg = { priority = 1; mime_matches = ["image/svg+xml"]; diff --git a/modules/by-name/lf/lf/ctpv/prev/xcf.sh b/modules/by-name/lf/lf/ctpv/prev/xcf.sh new file mode 100644 index 00000000..1603e337 --- /dev/null +++ b/modules/by-name/lf/lf/ctpv/prev/xcf.sh @@ -0,0 +1,37 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH + +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +cache_f="$cache_f" + +. %HELPERS + +xcf() { + # TODO: Add this (currently it fails, as gimp lacks the `python-fu` evaluator) <2024-11-25> + true + # # source: https://stackoverflow.com/a/20814599 + # # Start gimp with python-fu batch-interpreter + # gimp -i --batch-interpreter=python-fu-eval -b - << EOF + # import gimpfu + # + # def convert(filename): + # img = pdb.gimp_file_load(filename, filename) + # new_name = "$cache_f" + # layer = pdb.gimp_image_merge_visible_layers(img, 1) + # + # pdb.gimp_file_save(img, layer, new_name, new_name) + # pdb.gimp_image_delete(img) + # + # convert('${f}') + # + # pdb.gimp_quit(1) + # EOF +} + +# convert_and_show_image xcf + +exiftool -- "$f" -- cgit 1.4.1