How to convert GIF files to PNG or JPEG in OS X with command line?

2,438

Solution 1

No need for any additional tools. OS X has sips, which can convert images to (almost) any format.

For example, to convert every .gif to .jpeg, putting them into a folder called jpegs:

mkdir jpegs
sips -s format jpeg ./*.gif --out jpegs

Or, to recursively convert them using find, which will place a JPEG file with the same name as the GIF next to it.

find . -iname "*.gif" -type f -exec sh -c 'sips -s format jpeg "$0" --out "${0%.gif}.jpeg"' {} \;

Solution 2

Rather old question I see, but unfortunately the slhck's solution two doesn't work for me (OS X Mountain Lion, bash) I get an error.

This one works for me (after cd my_dir_with_gif command of course):

for i in *.gif; do sips -s format jpeg "${i}" --out "${i%gif}jpg"; done

And if you want to set the jpg compression as well ([low|normal|high|best|<percent>])

for i in *.gif; do sips -s format jpeg -s formatOptions 100 "${i}" --out "${i%jpg}png"; done

For other formats you should change extensions (remembering the sips jpg format is always jpeg, the extension could be .jpg)

This using sips but even better ImageMagick. It's a great tool, and I suggest to install it using brew see brew homepage

Share:
2,438

Related videos on Youtube

swetad90
Author by

swetad90

Updated on September 18, 2022

Comments

  • swetad90
    swetad90 over 1 year

    I understand that in order to restrict sending unnecessary metrics to the storage systems, we can use metrics_relabel_configs and action "labeldrop" to drop certain labels.

    All the examples I see, people are dropping labels as if they already knew all the labels associated with the metrics.

    While using exporters like node_exporters, process_exporter and kubestatemetrics for kubernetes, there are just too many metrics present. How do you decide which one to keep or drop ?

  • iolsmit
    iolsmit almost 7 years
    man sips ← This manual page is for Mac OS X version 10.9: sips -- scriptable image processing system.
  • Jay
    Jay over 2 years
    See below for updated answer.