Add script for converting Processing tif to png

This commit is contained in:
mmcwilliams 2024-04-20 10:01:32 -06:00
parent 1962790742
commit f5105d2c97
1 changed files with 29 additions and 0 deletions

29
scripts/image.sh Normal file
View File

@ -0,0 +1,29 @@
#!/bin/bash
set -e
if [[ "${1}" == "" ]]; then
echo "Please provide path to an image as your first argument"
exit 1
fi
if [[ "${2}" == "" ]]; then
echo "Please provide your DPI as your second argument"
exit 2
fi
IMAGE="${1}"
DPI=${2}
filename=$(basename -- "${IMAGE}")
extension="${filename##*.}"
NEW_IMAGE="${IMAGE/.$extension/.png}"
if [ -f "${IMAGE}" ]; then
convert -units PixelsPerInch "${IMAGE}" -density ${DPI} "${NEW_IMAGE}"
rm "${IMAGE}"
else
echo "${IMAGE} does not exist"
exit 3
fi