Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- file=$(sed -e's/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g' <<< "$QUERY_STRING" | xargs echo -e )
- file=${file##*/}
- file=${file%%;*}
- if [ -e "$file" ]; then
- sum=$(md5sum "$file" | sed -e 's/^\([0-9a-fA-F]*\)\s.*$/\1/')
- sum="/tmp/thumbs/$sum"
- mkdir -p /tmp/thumbs
- if ! [ -e "$sum" ]; then
- convert "$file" -auto-orient -thumbnail 250x90 -unsharp 0x.5 "gif:$sum"
- fi
- export TZ=UTC0
- t=$(stat --printf="%Y" "$sum")
- mod=$(awk "BEGIN{print strftime(\"%a, %d %b %Y %H:%M:%S %Z\", $t)}")
- cat <<-EOF
- Content-Type: image/gif
- Last-Modified: $mod
- EOF
- cat "$sum"
- else
- cat <<-EOF
- Status: 400 Bad Image Request
- EOF
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement