Image Optimizaton

How to batch convert images using a macOS terminal?

2 min read

Convert multiple images at once with the terminal on your Mac! Learn how to batch-convert images with a few simple commands. Get tips on automating the process and optimizing your workflow.

default avatar.
Aditya Patadia

1 March 2022

How to batch convert images using a macOS terminal?

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.

Command Structure

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

Batch Convert

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.

Supported Formats

Sips supports large number of image formats. Here is table on supported formats.

Format Read / Write
pdf Writable
psd Writable
icns Writable
gif Writable
exr Writable
bmp Writable
dds Writable
ico Writable
tga Writable
astc Writable
ktx Writable
heic Writable
heics Writable
jpeg Writable
jp2 Writable
pbm Writable
png Writable
pvr Writable
tiff Writable
dng Read
pict Read
cr2 Read
cr3 Read
crw Read
dxo Read
erf Read
raf Read
3fr Read
fff Read
dcr Read
mrw Read
mos Read
raw Read
rwl Read
nrw Read
nef Read
orf Read
orf Read
orf Read
raw Read
rw2 Read
pef Read
iiq Read
srw Read
sgi Read
arw Read
srf Read
sr2 Read
webp Read
avci Read
heif Read
mpo Read
pic Read

Subscribe to Latest Post

Don't miss out on latest article and more related posts.


Related Readings

Understanding Digital Video - Formats, Codecs, Containers

Understanding Digital Video - Formats, Codecs, Containers

This article will mainly discuss these three terms - Video formats, Video containers, and Video codecs. And how these terms are inter-connected.
Nitin Meena
Nitin Meena

29 Aug 2022 - 7 min read

LCP - What is Largest Contentful Paint?

LCP - What is Largest Contentful Paint?

Largest Contentful Paint is crucial in measuring page load performance. This blog aims to educate readers about LCP and related improvement measures.
Divyesh Patel
Divyesh Patel

9 Oct 2021 - 3 min read

How Page Speed and Image Optimization Affects Website SEO

How Page Speed and Image Optimization Affects Website SEO

Page speed and image optimization directly affect website SEO. Learn how Page Speed Affects SEO Rank and why images affect page speed. Discover the best practices to improve website page speed and how to optimize images for SEO.
Nitin Meena
Nitin Meena

8 Oct 2021 - 4 min read

Ready to get started?

Sign up and start optimizing your videos and images by up to 68% with Gumlet. No credit card is required. No credit card is required. You can also reach out to get a custom pricing estimate or to schedule a demo

Optimizing videos is hard, but
our pricing is not

Simple per-minute pricing with no hidden fees.
Pricing details

Effortlessly integrate Gumlet into your existing stack

Upload with API and set webhooks for output in minutes.
Integration guide