I have url links to image files I want to retrieve from the internet.
I can download the files using curl
without issue using:
curl "https://...web address..." > myfileName;
The image files are of various types, some .bmp
some .jpg
etc. I have been using sip
in Terminal on Mac osx to convert each to .png
files using:
sips -s format png downloadFileName --out newFileName.png
This works well on files I've saved as downloadedFileName
regardless of the starting file type.
As I have many files to process I wanted to pipe the output of the curl download directly into sips, without saving an intermediate file.
I tried the following (which combines my two working steps without the intermediate file name):
curl "https://...web address..." | sips -s format png --out fileName.png
And get a no file error: Error 4: no file was specified
.
I've searched the sip man pages but cannot find a reference for piped input and have been unable to find a useful answer searching SO or google.
Is there a way to process an image downloaded using curl directly in sips without first saving the file?
I do not necessarily need the solution to use a pipe, or even be on one line. I have a script that will cycle through a few thousand urls and simply want to avoid saving lots of files that will be deleted a line later.
I should add, I do not necessarily need to use sips either. However, any solution must be able to handle image files of unknown type (which sips does admirably) as no file extension is present on the files.
I don't have sips installed but its manpage indicates that it cannot read from stdin. However, if you use Bash or ZSH (MacOS default now) you can use process substitution, in this example I use
convert
which is a part of ImageMagick and can convert different image types too:After doing that this_is_fine.png will be the only file in the directory with no temporary files