Is it possible to optimise and resize an image with mozjpeg?

1

I want to be able to compress and resize and image with mozjpeg's cjpeg command

However according to the usage file it does not seem like cjpeg can do both in one single command.

Is it right?

If it is impossible to both compress and resize at the same time, should I use jpegtran to perform the resize function? If I should use jpegtran, then should the resize before or after the cjpeg optimises?

Anthony Kong

Posted 2019-03-12T04:00:43.927

Reputation: 3 117

1Perhaps I am blind, but in the usage page you link to, neither cjpeg nor jpegtran seem to have a resize option? The closest thing I spotted was djpeg, which has a scale option, but that's for decompressing .jpg images. – Anaksunaman – 2019-03-12T04:51:18.693

then how can one use this toolset to scale down a jpeg image? – Anthony Kong – 2019-03-12T04:56:12.947

It seems likely you would need to use djpeg with the scale option to turn the image into e.g. a bitmap of the size you wanted, then use cjpeg to recompress that e.g. bitmap into a .jpg format. – Anaksunaman – 2019-03-12T05:05:58.940

Looks like it is a no-go because djpeg is not is not tested and not maintained. https://github.com/mozilla/mozjpeg/issues/309#issuecomment-440674126

– Anthony Kong – 2019-03-12T05:07:26.957

Ah. That's too bad. =/ – Anaksunaman – 2019-03-12T05:11:46.073

@AnthonyKong, have you consider to change the base and use ImageMagic? – Romeo Ninov – 2019-03-12T06:58:25.383

No answers