From f5105d2c9707deaea322e1cfb09d074ee49c69b2 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sat, 20 Apr 2024 10:01:32 -0600 Subject: [PATCH] Add script for converting Processing tif to png --- scripts/image.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scripts/image.sh diff --git a/scripts/image.sh b/scripts/image.sh new file mode 100644 index 0000000..45c3a02 --- /dev/null +++ b/scripts/image.sh @@ -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 \ No newline at end of file