Created
July 11, 2018 19:35
-
-
Save ernstki/742a2140047e74804572d7e3e95a80d4 to your computer and use it in GitHub Desktop.
Create a drop shadow for screenshots using ImageMagic's 'convert'
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
# add a 1-pixel #777 border and a 2-pixel offset drop shadow of 5 px radius | |
# | |
# source: https://stackoverflow.com/a/7136561 | |
function dropshadow() { | |
# inner border color and radius | |
local ibc=${DS_INNER_BORDER_COLOR:-#777} | |
local ibr=${DS_INNER_BORDER_RADIUS:-1} | |
# drop shadow color, alpha, width and offset | |
local dsc=${DS_DROP_SHADOW_COLOR:-black} | |
local dsa=${DS_DROP_SHADOW_ALPHA:-80} | |
local dsw=${DS_DROP_SHADOW_WIDTH:-3} | |
local dso=${DS_DROP_SHADOW_OFFSET:-2} | |
if ! [ -f "$1" ]; then | |
echo "ACK! File '$1' not found or unreadable!" >&2 | |
return 1 | |
fi | |
# slip '-shadow' in between the filename and its original extension | |
local of="${1%.*}-shadow.${1##*.}" | |
convert "$1" -bordercolor $ibc -border $ibr \( +clone -background $dsc \ | |
-shadow ${dsa}x$dsw+$dso+$dso \) +swap -background white -layers \ | |
merge +repage "$of" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment