Skip to content

Instantly share code, notes, and snippets.

@caiosba
Created April 8, 2017 14:49
Show Gist options
  • Save caiosba/de3a431e39f27adfc2a01e58a390262d to your computer and use it in GitHub Desktop.
Save caiosba/de3a431e39f27adfc2a01e58a390262d to your computer and use it in GitHub Desktop.
Upload an image to Imgur - no API keys needed
#!/bin/bash
# Usage: ./upload-img-to-imgur.sh <image file path>
# Output: URL to the image on Imgur
filepath=$1
content_type="image/png"
filename="$(basename filepath)"
curl -X POST "http://imgur.com/upload" \
-H "Referer: http://imgur.com/upload" \
-F "Filedata=@$filepath;filename=$filename;type=$content_type" 2>/dev/null | sed 's/^{"data":{"hashes":\["\([^"]\+\).*/http:\/\/imgur.com\/\1/g'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment