Created
May 29, 2020 17:05
-
-
Save claudioc/ac4be1843dded18cf86243dd8b668536 to your computer and use it in GitHub Desktop.
Script which finds the newest screenshot image and adds a shadow to it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ $# -eq 0 ]; then | |
echo "Needs the filename as the first argument" | |
exit -1 | |
fi | |
type /usr/local/bin/convert >/dev/null 2>&1 || { echo >&2 "The convert command must be available."; exit 1; } | |
input_filename="${1}" | |
output_dir="./" | |
if [ "${input_filename}" == "--last-screenshot" ]; then | |
ss_dir="/Users/claudioc/Screenshots/" | |
input_filename="$(ls -1rt ${ss_dir}Screenshot* | tail -1)" | |
if [[ "${input_filename}" =~ "_shadow" ]]; then | |
echo "Nothing to be done" | |
exit 0 | |
fi | |
output_dir="${ss_dir}" | |
fi | |
# https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash#965072 | |
filename=$(basename -- "${input_filename}") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
/usr/local/bin/convert "${input_filename}" \( +clone -background black -shadow 30x8+0+0 \) +swap -background none -layers merge +repage "${output_dir}${filename}_shadow.${extension}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment