I have some image urls, I want to download them. But these files have different suffix, such as .jpg, .png or .bmp. I also want to change them into a unified format, such as .JPEG. So I want to use the curl command to download the image into the memory cache, then use the convert command in ImageMagick package to convert the data format into .JPEG format. Is there a method to do this work?

    `curl http://aa.com/a.jpg`
    `convert a.jpg 00001.JPEG`
    `rm a.jpg`
    `curl http://bb.com/b.png`
    `convert b.png 00002.JPEG`
    `rm b.png`

I want to simplify this procedure, let the temp files save into cache, then not save into the disk directly, so lessen the burden of the disk. Is there any way to use pipeline technology to do this work? such as

    `curl http://aa.com/a.jpg | convert ... | ...`

Thanks in advance.

有帮助吗?

解决方案

You can do as follows:

curl http://aa.com/a.jpg | convert - 00001.jpeg
curl http://bb.com/b.jpg | convert - 00002.jpeg

The file are then in JPEG format:

user@host:~# file 00001.jpeg
file.jpeg: JPEG image data, JFIF standard 1.01
user@host:~# file 00002.jpeg
file.jpeg: JPEG image data, JFIF standard 1.01

That's it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top