Convert HEIC images to compressed JPEG

Public
GH
geoff
·
as
· Created 23d ago
I've got a bunch of images in this folder. They are HEICs. I want you to convert them to JPEGs that are 1920px and no bigger than 500 kilobytes.

The user wants to convert HEIC images to JPEGs with specific requirements:

  1. Convert HEIC files to JPEG
  2. Resize to 1920px (presumably width, maintaining aspect ratio)
  3. Keep file size under 500KB

I can see there are 7 HEIC files in the directory. I'll need to use a command line tool to do this conversion. On macOS, I can use sips (Scriptable Image Processing System) which is built-in, or magick if ImageMagick is installed.

Let me plan this task:

  1. Check what image conversion tools are available
  2. Convert each HEIC file to JPEG with the specified constraints
  3. Verify the results

I should use the todo_write tool to plan this task.

Updated TODOs
which sips
/usr/bin/sips
Updated TODOs
for file in *.HEIC; do
    output="${file%.HEIC}.jpg"
    sips -s format jpeg -Z 1920 --setProperty formatOptions 70 "$file" --out "$output"
done
/Users/ghuntley/Desktop/as/IMG_0473.HEIC
/Users/ghuntley/Desktop/as/IMG_0473.jpg
/Users/ghuntley/Desktop/as/IMG_0529.HEIC
/Users/ghuntley/Desktop/as/IMG_0529.jpg
/Users/ghuntley/Desktop/as/IMG_0534 2.HEIC
/Users/ghuntley/Desktop/as/IMG_0534 2.jpg
/Users/ghuntley/Desktop/as/IMG_0534 3.HEIC
/Users/ghuntley/Desktop/as/IMG_0534 3.jpg
/Users/ghuntley/Desktop/as/IMG_0534.HEIC
/Users/ghuntley/Desktop/as/IMG_0534.jpg
/Users/ghuntley/Desktop/as/IMG_0535.HEIC
/Users/ghuntley/Desktop/as/IMG_0535.jpg
/Users/ghuntley/Desktop/as/IMG_0540.HEIC
/Users/ghuntley/Desktop/as/IMG_0540.jpg
Updated TODOs
ls -lh *.jpg
-rw-r--r--@ 1 ghuntley  staff   516K 25 Jun 17:12 IMG_0473.jpg
-rw-r--r--@ 1 ghuntley staff 590K 25 Jun 17:12 IMG_0529.jpg
-rw-r--r--@ 1 ghuntley staff 309K 25 Jun 17:12 IMG_0534 2.jpg
-rw-r--r--@ 1 ghuntley staff 309K 25 Jun 17:12 IMG_0534 3.jpg
-rw-r--r--@ 1 ghuntley staff 309K 25 Jun 17:12 IMG_0534.jpg
-rw-r--r--@ 1 ghuntley staff 442K 25 Jun 17:12 IMG_0535.jpg
-rw-r--r--@ 1 ghuntley staff 485K 25 Jun 17:12 IMG_0540.jpg
for file in IMG_0473.jpg IMG_0529.jpg; do
    sips -s format jpeg --setProperty formatOptions 60 "$file" --out "${file%.jpg}_compressed.jpg"
done
/Users/ghuntley/Desktop/as/IMG_0473.jpg
/Users/ghuntley/Desktop/as/IMG_0473_compressed.jpg
/Users/ghuntley/Desktop/as/IMG_0529.jpg
/Users/ghuntley/Desktop/as/IMG_0529_compressed.jpg
ls -lh *_compressed.jpg
-rw-r--r--@ 1 ghuntley  staff   445K 25 Jun 17:12 IMG_0473_compressed.jpg
-rw-r--r--@ 1 ghuntley staff 511K 25 Jun 17:12 IMG_0529_compressed.jpg