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 ! smile )

┌─(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 :

http://i.imgur.com/ks3PC.png


And the code :
(it's my first attempt to bash script ... sorry for bad codage roll )

#!/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 wink

Last edited by Kookaburra (2011-02-08 17:14:51)

Re: [Script] Screenshot + Upload on "imgur" (Clickable thumbnail)

http://i.imgur.com/7Z1uS.png


nice one

Re: [Script] Screenshot + Upload on "imgur" (Clickable thumbnail)

Update of the first post :
- more parameters.
- more return in the terminal (progress-bar, ...)
- the width is fixed to 640 pixels.
- copy the link into clipboard.

;-)

Re: [Script] Screenshot + Upload on "imgur" (Clickable thumbnail)

ha-ha good one - works...
could you please add to the first post that one should install xclip roll
http://i.imgur.com/22kLH.png

Re: [Script] Screenshot + Upload on "imgur" (Clickable thumbnail)

TRF wrote:

could you please add to the first post that one should install xclip roll

See in the script ... wink

#     Dependencies: scrot xclip libnotify* notify-send curl imagemagick



Some more tests ... Shadows effects ... small thumbnails this "Polaroid" effect ... coming soon smile

  http://i.imgur.com/30IEw.png


http://i.imgur.com/ytcpq.png http://i.imgur.com/2G2ZM.png


Imagemagick is a very strong application, I like it ! tongue

Re: [Script] Screenshot + Upload on "imgur" (Clickable thumbnail)

kook wrote:

http://i.imgur.com/7Z1uS.png


nice one

Is it just the font you used in the terminal, or is there something wrong with your fonts? (Panels look ok tho, so....:/ )

TRF wrote:

http://i.imgur.com/22kLH.png

What WM is that?

Last edited by Unia (2011-02-09 20:07:01)

Let's do it and don't screw it.
      Github || Deviantart

Re: [Script] Screenshot + Upload on "imgur" (Clickable thumbnail)

@unia xfce
top xfce-panel (16 pixel)
bottom - conky
right - adeskbar

@Kookaburra
sorry missed it in the script - just copy+paste to test it ...