Topic: [Script] Screenshot + Upload on "imgur" (Clickable thumbnail)
Just a simple script to take a screenshot, upload it on Imgur and give a Clickable thumbnail to copy on your favorite forum (crunchbanglinux.org, of course !
)
┌─(kooka@EeeGeek)────────────────────────────────────────────────────────────────────────────────────────────────(07-02-11)─┐
└─(/home/kooka)──> % kooka-screenshot ──(21:39:24)─┘
Screenshot in 5 seconds ...
... Screenshot done !
... Thumbnail generated !
Upload of the screenshot ...
######################################################################## 100,0%
Upload of the thumbnail ...
######################################################################## 100,0%
The links :
Screenshot :
http://i.imgur.com/ks3PC.png
Clickable thumbnail :
[url=http://i.imgur.com/QVdIi.png][img]http://i.imgur.com/ks3PC.png[/img][/url]
(link copy into Clipboard, you just have to past it where you want !)The thumbnail look like this :
And the code :
(it's my first attempt to bash script ... sorry for bad codage
)
#!/bin/bash
#
# Kooka-Screenshot
# By Kookaburra ( kookaburra45 0 gmail . com )
# Based on differents scripts view on the Internet
# Thanks to all of the authors :-)
#
# Links :
# http://www.webupd8.org/2010/01/scripts-to-take-screenshot-and-upload.html
# http://sirupsen.com/a-simple-imgur-bash-screenshot-utility/
# http://forum.ubuntu-fr.org/viewtopic.php?id=183632&p=1
#
# Description: Very simple script to take a screenshot and upload it to http://imgur.com/.
# The URL of a "clickable thumbnail" will then be injected into your clipboard.
#
# Dependencies: scrot xclip libnotify* notify-send curl imagemagick
#
# Installation:
# Move the file to a local bin. And put the path of this bin, into your path.
# From then on, you can either activate it via your terminal, or via
# your window manager or similar, so you can bind it to a keycombination.
#
# Version 1.1
# 08/02/2011
#
########################### Parameters ###########################
# Folder for backup :
FOLDER="/path/to/your/screenshots/folder"
# Delay to take screenshot :
DELAY=5
# Dimensions of the thumbnail :
WIDTH=640
# (the height is automatically calculate)
##################################################################
function uploadImage {
curl --progress-bar -F "image=@$1" -F "key=486690f872c678126a2c09a9e196ce1b" http://imgur.com/api/upload.xml | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "http://i.imgur.com/[^<]*"
}
echo "Screenshot in $DELAI seconds ..."
cd $FOLDER
scrot -d $DELAY '%Y-%m-%d--%s_$wx$h_scrot.png'
cd ~/
scrot shot.png
echo "... Screenshot done !"
convert shot.png -thumbnail ${WIDTH}x -unsharp 0x.5 shot-thumb.png
echo "... Thumbnail generated !"
echo ""
echo "Upload of the screenshot ..."
uploadImage "shot.png" | xclip -selection c
IMAGE1=$(xclip -selection c -o)
rm "shot.png"
echo "Upload of the thumbnail ..."
uploadImage "shot-thumb.png" | xclip -selection c
IMAGE2=$(xclip -selection c -o)
rm "shot-thumb.png"
echo ""
echo "The links :"
echo ""
echo "Screenshot :"
echo "$IMAGE1"
echo ""
echo "Clickable thumbnail :"
echo "[url=$IMAGE1][img]$IMAGE2[/img][/url]" | xclip -selection clipboard
echo "(link copy into Clipboard, you just have to past it where you want !)"
notify-send "Done"I hope it will be useful for you, like for me ![]()
Last edited by Kookaburra (2011-02-08 17:14:51)





