Shelify python scripts

This commit is contained in:
oitsjustjose 2026-06-20 19:24:43 -05:00
commit cf03a4ffc9
13 changed files with 239 additions and 342 deletions

34
linux/convert-heic Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
if [[ -z "$1" ]]; then
echo "Missing required argument [heif_file]!"
exit 1
fi
# Set up the python environment
if [ ! -f "/tmp/shell-scripts/venv/bin/python" ]; then
mkdir -p /tmp/shell-scripts
python3 -m venv /tmp/shell-scripts/venv > /dev/null 2>&1
fi
# Install reqs
/tmp/shell-scripts/venv/bin/pip install pillow pillow-heif > /dev/null 2>&1
# Finally run the script
/tmp/shell-scripts/venv/bin/python << EOF
from PIL import Image
from pillow_heif import register_heif_opener
from pathlib import Path
from sys import exit
path = Path("$1").resolve()
if path.suffix.lower() != ".heic":
exit(0)
register_heif_opener()
im = Image.open(path)
im.save(path.with_suffix(".jpeg"), quality=100)
EOF