Created
November 18, 2015 06:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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