More updates!
This commit is contained in:
parent
3967e285b6
commit
c501597c19
10 changed files with 66 additions and 86 deletions
29
linux/convert-heic.sh
Executable file
29
linux/convert-heic.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/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
|
||||
|
||||
|
||||
Loading…
Reference in a new issue