Skip to content

Instantly share code, notes, and snippets.

@stripedpurple
Created November 18, 2015 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stripedpurple/447336b2426401c04fb2 to your computer and use it in GitHub Desktop.
Save stripedpurple/447336b2426401c04fb2 to your computer and use it in GitHub Desktop.
Add this function to your .bash_profile to upload all the images in a directory to imgur.com
function uploadImage {
ext=$1
if [ "$ext" == "help" ]; then
printf "Description:\n\tUploads all images in directory of extension type specified to imgur.com\nExample:\n\tuploadImage jpg\nFile Types:\n\tPEG, PNG, GIF, APNG, TIFF, BMP, PDF, XCF (GIMP). Please note that TIFF, BMP, PDF and XCF (GIMP) will be converted to PNG on upload. PNGs over 756KB are automatically converted to JPG.\n\n\tImgur does not currently support WEBM, MP4, or GIFV uploads. They will need to be converted before upload.\n"
else
for f in *".$1";
do
printf "$f\t"
curl -s -F "image=@$f" -F "key=26ff5c40cbedf50e7f81124ab473c1cc" https://imgur.com/api/upload.xml | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "http://i.imgur.com/[^<]*"
done
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment