29 lines
664 B
Shell
Executable file
29 lines
664 B
Shell
Executable file
#!/bin/bash
|
|
|
|
if [[ -z "$1" ]]; then
|
|
echo "Missing required argument [heif_file]!"
|
|
exit 1
|
|
fi
|
|
|
|
# Set up the python environment
|
|
mkdir -p /tmp/shell-scripts
|
|
python3 -m venv /tmp/shell-scripts/env > /dev/null 2>&1
|
|
# 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
|
|
|
|
|