feat(guz,apps,packages): untrack, small utility to remove metadata from files

This commit is contained in:
Guz
2025-03-14 22:13:03 -03:00
parent 1709442746
commit 8c3af63e12
4 changed files with 38 additions and 0 deletions

View File

@@ -137,6 +137,8 @@
...
}: {
davincify = pkgs.callPackage ./packages/davincify {};
untrack = pkgs.callPackage ./packages/untrack {};
neovim = inputs.neovim.packages.${pkgs.system}.default;
devkit =

View File

@@ -40,11 +40,13 @@
# Media
ffmpeg
exiftool
krita
davinci-resolve
])
# Utils
++ (with self.packages.${pkgs.system}; [
davincify
untrack
]);
}

View File

@@ -0,0 +1,9 @@
{
pkgs,
lib,
...
}:
pkgs.writeShellScriptBin "untrack" ''
function exitftool() { ${lib.getExe pkgs.exiftool} "$@"; }
${builtins.readFile ./untrack.sh}
''

View File

@@ -0,0 +1,25 @@
function rand_hex() {
local length="$1"
cat /dev/urandom | tr -cd 'a-f0-9' | head -c "$length"
}
# TODO: Support for directories
function untrack() {
local file="$1"
local filename="$(basename "$file")"
local ext="${filename##*.}"
local directory="$(dirname "$file")"
local output_file="$directory/$(rand_hex 6).$ext"
cp "$file" "$output_file"
exiftool \
-overwrite_original \
-all= \
"$output_file"
}
untrack "$1"