From 6e61dc69a46b676a32fb8c85fdc33223f0fbce4e Mon Sep 17 00:00:00 2001 From: shmibs Date: Tue, 8 Jul 2014 11:28:59 -0700 Subject: imagemagick backdrop shadowing this isn't going too well so far, but it almost sort of works. it'd be nice to be able to just draw the shadow on top directly rather than using a pre-drawn shadow image, but imagemagick makes no sense --- .zshrc | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index a0df374..4e14600 100644 --- a/.zshrc +++ b/.zshrc @@ -133,11 +133,14 @@ ssh-scrot() { date=$(date +'%Y-%m-%d') - ssh shmibbles.me "mkdir -p http/img/scrot/$date" + folder="http/img/scrot" + ssh shmibbles.me "mkdir -p $folder/$date" if [[ "${?#0}" != "" ]]; then return 1 fi + + ssh shmibbles.me "rm $folder/current 2>/dev/null; ln -s $folder/$date $folder/current" for i in {3..1}; do echo -n "$i " @@ -162,3 +165,34 @@ ssh-scrot() { rm /tmp/$name.png /tmp/${name}_small.png } + +# yay imagemagick +update-backdrops() { + resolution=( ${(s:x:)$(xrandr | grep "*+" | cut -d ' ' -f 4)} ) + IFS=$'\n' + for f in $(find ~/backdrops/(*.png|*.jpg)); do + + base="$(basename $f)" + geometry=( ${(s: :)$(identify -format "%w %h" $f)} ) + if [[ $(calc "(${geometry[0]}/${geometry[1]}) > 1.7778" | \ + tr -d '\t') != "0" ]]; then + scale="x${resolution[1]}" + crop="${resolution[0]}x" + else + scale="${resolution[0]}x" + crop="x${resolution[1]}" + fi + + if [[ ! -f "$HOME/backdrops/shadowed/$base" ]]; then + echo "$base..." + convert \ + -page +0+0 "$f" \ + -scale $scale \ + -crop $crop \ + -page +0+0 "$HOME/backdrops/dropshadow/shadow.png" \ + -composite \ + "$HOME/backdrops/shadowed/$base" + fi + + done +} -- cgit v1.2.3