문제

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