How can I upload a photo to imgur from the command line and get their direct link?

Is there a way I can upload some photos to imgur.com via the command-line and get their direct link as result in a text file?


Solution 1:

The list of (mostly third-party) tools on the imgur website (http://imgur.com/tools) features three bash scripts:

  • Bart's Bash Script Uploader by Bart Nagel

    A simple bash script to upload an image to imgur from the commandline. Run imgur images/delicious/cake.jpg to upload, print the new URL to stdout, print the delete page URL to stderr and put URL on the X clipboard for easy pasting.

  • img Bash Script Uploader by Ceryn

    A minimalistic screenshot uploader for Linux. Supports screen selection.

  • Imgur-Screenshot by jomo

    A simple screenshot bash script for Linux and OS X. Just run the script and select a portion of your screen to upload. The direct link to the image is then copied to your clipboard.

Solution 2:

i tried myself today on imgur and it's quite complex , the documentation is pretty bad written so the procedure is not clear . May i suggest to try imagebin.ca ?! cuz has a simpler API to upload files :

curl -s -F key="YOURKEY_JUST_REGISTER_ON_IMAGEBIN.CA_and go_on_profile_to get it" \
 -F file="@$1" \
 https://imagebin.ca/upload.php | awk -F':' '/url:/{gsub(/url:/,"") ; print $0 }'

if you are using linux and kde =>

qdbus org.kde.klipper /klipper org.kde.klipper.klipper.setClipboardContents "$(curl -s -F key="YOURKEY_________PLEASE_EDIT_IT" \
 -F file="@$1" \
 https://imagebin.ca/upload.php | awk -F':' '/url:/{gsub(/url:/,"") ; print $0 }' )"