4

I am looking for a way to compress jpeg images on a Mac from Terminal. Basically, a library like pngquant, except it is for jpeg format.

Are you aware of a software that does that?

1
  • The question reads as if you are looking to losslessly compress a jpg file - which of course cannot be done. All you can do is make it smaller by making it lossier.
    – Tetsujin
    Commented May 12, 2017 at 16:59

1 Answer 1

8

You can use GraphicsMagick which is a newer and more efficient image processing system than ImageMagick. Both apps are available via direct download, MacPorts, and Homebrew.

I suggest using GraphicsMagick as it is smaller and faster than ImageMagic. The commands are generally the same with the only difference being that you prepend a gm with the GraphicsMagick tool. gm is the binary with the commands convert, identify, mogrify, etc. are arguments where as IM, the same arguments are individual binaries.

The commands are as follows:

  • GraphicsMagick:

    gm convert -quality X% source.jpg result.jpg

  • ImageMagick:

    convert -quality X% source.jpg result.jpg

X is a positive integer value (i.e. 85 for 85%); source and result are the original filename and the output filename.

3
  • 2
    I think the command is actually "convert", not "compress". Commented Apr 6, 2022 at 19:58
  • I confirmed that it should be "convert" in 2022
    – Hang Chen
    Commented Dec 29, 2022 at 19:29
  • 1
    @HangChen…I’ve updated with correct command and a better tool
    – Allan
    Commented Dec 29, 2022 at 20:20

Not the answer you're looking for? Browse other questions tagged .