MacOS preview application provides a very easy way to convert and process images if you want a quick way to convert a few images. This article by MacRumors describes an easy way to achieve it.
This becomes a problem if you ever want to convert large number of images. Opening thousands of images and then converting them using preview will mostly end up hanging mac for saveral minutes.
There is however a very handy command line utility called sips that comes built-in macOS and provides an easy way to convert thounsands of images in efficient manner.
To convert single file with sips, here is command syntax:
sips -s format [image type] [file name] --out [output file]
For example if you want to convert file named test.png, here is sips syntax:
sips -s format jpeg test.png --out test.jpg
This command does not take multiple inputs but it's super easy to convert multiple files with shell scripting:
for i in *.png; do sips -s format jpeg $i --out Converted/$i.jpeg;done
Convert to HEIF / HEIC
It's also possible to convert all jpeg images to HEIC to save space before storing them. HEIC images will be 30-50% smaller for same quality as JPEG.
for i in *.jpg; do sips -s format heic -s formatOptions 75 $i --out converted/$i.heic;done
This command will convert images to
heic and put converted images to "converted" folder. Here, the
formatOptions argument sets output quality for the image. Value of 0 means most compressed and 100 means lossless.
A 3-second delay in page load time leads to upto 60% drop in traffic. Find out how fast your website will load with Gumlet’s industry-leading image optimization.
Sips supports large number of image formats. Here is a table on supported formats.
|Format||Read / Write|