I have been trying to use mozjpeg in my Go application for JPEG compression, since it seems to have very good quality when used through the cjpeg command-line utility it provides.
However, pictures compressed with my application have inferior quality - a lot more JPEG artefacts with the same quality level.
I am using go bindings for libjpeg-turbo / mozjpeg from https://github.com/subuk/go-mozjpeg/blob/master/jpeg/compress.go
My own code does not seem to be too complex:
libjpegOptions := jpeg.EncoderOptions{
Quality: 92,
OptimizeCoding: true,
ProgressiveMode: true,
}
err = jpeg.Encode(buf, m, &libjpegOptions)
if err != nil {
return nil, err
}
Both applications seem to link to the same version of mozjpeg library, installed with Homebrew:
$ otool -L /opt/mozjpeg/bin/cjpeg
/opt/mozjpeg/bin/cjpeg:
/opt/mozjpeg/lib/libjpeg.62.dylib (compatibility version 65.0.0, current version 65.0.0)
/usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 51.0.0, current version 51.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
$ otool -L /Users/fabio/Code/go/bin/imageproxy
/Users/fabio/Code/go/bin/imageproxy:
/opt/mozjpeg/lib/libjpeg.62.dylib (compatibility version 65.0.0, current version 65.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1451.0.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 58286.41.2)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
What could I try next to ensure that my application is using the same settings as cjpeg?