Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I upload multiple images to an imgur album from command line?

Tags:

bash

curl

sed

imgur

This is what I have now, it works on a single image.

curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" -F image=@/path/to/image https://api.imgur.com/3/upload.xml

to get the result open in your browser, I have

curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" -F image=@/path/to/image https://api.imgur.com/3/upload.xml | grep -Eo '<[a-z_]+>http[^<]+'|sed 's/^<.\|_./\U&/g;s/_/ /;s/<.*>//' | sed  's/^.*imgur\.com\//http:\/\/imgur.com\//g;s/\.[^.]*$//' | xargs xdg-open 

but how can I upload multiple images to an anonymous album ?

I knew I can create an album with

curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" -F "title=imgur"  https://api.imgur.com/3/album

Then I guess I need to make some curl calls on each and every one of my images to add them to the album one by one? Or There is some magic command that I can do all of these in just one curl call? (create the album, upload multiple images, and get the album link back)

Imgur image upload api says there is a album key, but I don't know how to pass it with curl.(I can see the deletehash from the result of last album creation call.)

The ultimate goal is to add some menu to kde dolphin browser( as servicemenu ) Single image upload is already working.

screenshot

like image 949
Shuman Avatar asked Dec 08 '25 05:12

Shuman


1 Answers

find command is your friend.

Suppose you wish to upload all the .png images you could do the below stuff.

find /path/to/images/folder -maxdepth 1 -type f  -name "*.png"  \
     -print0 | while read -rd '' filename
do
curl -vH "Authorization: Client-ID 3e7a4deb7ac67da" \
     -F image=@"$filename" https://api.imgur.com/3/upload.xml
done
like image 161
Мона_Сах Avatar answered Dec 10 '25 19:12

Мона_Сах



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!