Coder Perfect

Using curl to download an image in Ubuntu


I’d like to save an image found at×144-precomposed.png to my local machine. Now I know how to use the curl command to download distant files from the terminal. So, in order to download the image into my local system, I typed the following into my terminal:


However, this does not appear to work, thus there must be another way to use curl to get photos from the Internet. What is the proper method to use this command to download images?

Asked by Manas Chaturvedi

Solution #1

ET made a request. It just returns the contents from the supplied URI. You will not be able to save the file on your local PC.

When you do,

$ curl

You will receive binary data in the following format:

                   |�>�$! <R�HP@T*�Pm�Z��jU֖��ZP+UAUQ@�
��{X\� K���>0c�yF[i�}4�!�V̧�H_�)nO#�;I��vg^_ ��-Hm$$N0.
���%Y[�L�U3�_^9��P�T�0'u8�l�4 ...

You can use the following to save this:

$ curl > image.png

to save the unprocessed image data in a file

However, using wget is a simpler option.

$ wget
$ ls

Answered by ddavison

Solution #2

Curl -O (capital “o,” not a zero) will do the same thing as wget if you don’t have or wish to install it. For example, wget is missing from my old netbook, and it’s a 2.68 MB installation that I don’t require.

curl -O

Answered by jwh

Solution #3

Use uppercase -O if you wish to maintain the original name.

curl -O×144-precomposed.png

If you want to save remote file with a different name — use lowercase -o

curl -o myPic.png×144-precomposed.png

Answered by daGo

Solution #4

Make a new file called files.txt and paste the URLs into it one by one. Then run the command below.

xargs -n 1 curl -O < files.txt


Answered by korchix

Solution #5

For those who have been denied permission to save a file, here is the command that worked for me:

$ curl --output py.png

Answered by George Garchagudashvili

Post is based on