potato.sh - jscancer - Javascript crap (relatively small) | |
git clone git://git.codemadness.org/jscancer | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
potato.sh (1012B) | |
--- | |
1 #!/bin/sh | |
2 | |
3 image2html() { | |
4 w=$(identify -ping -format '%w' "$1" 2>/dev/null) | |
5 h=$(identify -ping -format '%h' "$1" 2>/dev/null) | |
6 | |
7 if test "$w" = "" -o "$h" = ""; then | |
8 echo "no image dimensions found for: $1" >&2 | |
9 return | |
10 fi | |
11 | |
12 # get primary color, sortof... | |
13 bgcolor=$(convert -blur 16x16 -scale 16x16! -dither FloydSteinbe… | |
14 sort -t ':' -r -n | \ | |
15 LC_ALL=C awk -F ' ' '{ print $3; exit }') | |
16 | |
17 data=$(convert -scale 16x16! -quality 50 -strip "$1" \ | |
18 -define webp:filter-strength=50 \ | |
19 -define webp:lossless=false \ | |
20 -define webp:target-size=100 \ | |
21 "webp:-" | base64 | tr -d '\n') | |
22 | |
23 echo "<div style=\"display:inline-block;background:${bgcolor} ur… | |
24 echo "<img src=\"$1\" width=\"$w\" height=\"$h\" alt=\"\" loadin… | |
25 echo "</div>" | |
26 } | |
27 | |
28 if test "$#" -lt 1; then | |
29 echo "usage: $0 <image> ..." >&2 | |
30 exit 1 | |
31 fi | |
32 | |
33 for f in "$@"; do | |
34 image2html "$f" | |
35 done |