jcomeau_ictx

netmeme.sh

Sep 11th, 2014
247
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. image_in=$1
  3. if [ -z "$1" ]; then image_in=~/downloads/Nicos_Anastasiades_at_EPP_HQ.jpg; fi
  4. top_text=$2
  5. if [ -z "$2" ]; then
  6.  top_text="CYPRUS'S PRESIDENT DESCRIBES HOW\nHIS COUNTRY SURVIVED"
  7.  top_text="${top_text}\nTHE 2013 FINANCIAL CRISIS"
  8. fi
  9. bottom_text=$3
  10. if [ -z "$3" ]; then
  11.  bottom_text="WE SEIZED ALL FUNDS\nIN EXCESS OF €100,000\n"
  12.  bottom_text="${bottom_text}FROM ALL BANK ACCOUNTS-\n"
  13.  bottom_text="${bottom_text}THE OPPOSITE OF WHAT AMERICA DOES"
  14. fi
  15. image_out=$4
  16. if [ -z "$4" ]; then
  17.  image_out=/tmp/image_out.jpg
  18. fi
  19. # the following sets max dimension to 640
  20. convert -resize 640x640 $image_in /tmp/image_in.jpg
  21. width=$(identify -format '%w' /tmp/image_in.jpg)
  22. height=$(identify -format '%h' /tmp/image_in.jpg)
  23. lineheight=$(echo "$height * .05" | bc)  # pixels = 1/20 height
  24. halfline=$(echo "$lineheight / 2" | bc)
  25. margin=$(echo "$lineheight * .3" | bc)
  26. pointsize=$(echo "$lineheight * .75" | bc)  # points = pixels * .75
  27. pagepoints=$(echo "$pointsize * .75" | bc)  # pagename pointsize
  28. copyright=$(echo "$pointsize * .40" | bc)  # copyright pointsize
  29. convert \
  30.  -geometry $width \
  31.  -font Impact-Regular \
  32.  -background none -fill white -stroke black -strokewidth 1 \
  33.  -pointsize $pointsize -gravity center \
  34.  label:"$top_text" /tmp/top_text.gif
  35. convert \
  36.  -geometry $width \
  37.  -font Impact-Regular \
  38.  -background none -fill white -stroke black -strokewidth 1 \
  39.  -pointsize $pointsize -gravity center \
  40.  label:"\"$bottom_text\"" /tmp/bottom_text.gif
  41. offset=$(echo $(identify -format %h /tmp/bottom_text.gif) + $halfline | bc)
  42. convert \
  43.  -font Impact-Regular \
  44.  -background none -fill gray57 -stroke gray13 -strokewidth 1 \
  45.  -pointsize $pagepoints -gravity west \
  46.  label:"FB.com/USACutup" /tmp/pagename.gif
  47. convert \
  48.  -font Impact-Regular \
  49.  -background none -fill gray57 -stroke gray13 -strokewidth 1 \
  50.  -pointsize $copyright -gravity west \
  51.  label:"jc.unternet.net" /tmp/copyright.gif
  52. composite -geometry +0+$margin -gravity north /tmp/top_text.gif \
  53.  /tmp/image_in.jpg \
  54.  $image_out
  55. composite -geometry +0+$margin -gravity south /tmp/bottom_text.gif \
  56.  $image_out $image_out
  57. composite -geometry +$margin+$offset -gravity southwest /tmp/pagename.gif \
  58.  $image_out $image_out
  59. composite -geometry +1+1 -gravity southeast /tmp/copyright.gif \
  60.  $image_out $image_out
  61. echo Netmeme was written to $image_out. >&2
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×