Can the JPEG “quality” shown by ImageMagick be removed?

Asked 8/5/2018

195 views

2 answers

0

When I run identify -verbose image.jpg in ImageMagick, some JPEGs show a quality value and some do not. Is that quality field actual metadata that can be removed from a JPG, or is it derived from the file’s compression settings? If I only want to strip metadata, what should I use instead?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

8y ago

2 Answers

34

In short: there is no reason to care about this value and it its presence does not make your file larger.

identify -verbose filename(s)

only displays the quality if the image uses the standard quantization matrix. You can use nonstandard matrix (-define jpeg:q-table=...) to make this value disappear.

The quality will be, however still displayed when the (better) command

identify -format 'the quality of %f is %Q' filename(s)

is used (better for displaying the quality that is, it only looks for this value instead of performing the detailed analysis of the image, which makes it much faster than "identify -verbose")

The thing is, you can't really remove the quality value, similarly how you can't "remove" the image width or height. It is the inherent attribute of the JPEG image and is calculated by ImageMagick from the JPEG quantization tables contained in the file.

It does not have, however, any standarized meaning. The value displayed by ImageMagick corresponds to the Independent JPEG Group's libjpeg quality setting (also used in GIMP and many others), other software packages can have their own incompatible quality measures. In such nonstandard case, ImageMagick can only estimate the quality, by looking what standard quality table is similar to the actual one. Use the "-debug All" will (among others) display the following:

Quality: 85 (exact)

or

Quality: 85 (approximate)

For some reason, "-verbose" only displays the value when it is exact, while "-format %Q" will always display the quality, even if it is just approximate.

Originally by user32811. Source · Licensed CC BY-SA 4.0

user32811

8y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

No. The quality reported by ImageMagick is not normal metadata you can strip from a JPEG. It is effectively derived from the JPEG’s compression/quantization tables, so it’s an inherent characteristic of how the file was encoded, not like EXIF or IPTC data.

identify -verbose may omit it for some files because it only shows that value in certain cases, such as when standard quantization tables are recognized. Other JPEGs may appear as “unknown” simply because the encoding doesn’t match what ImageMagick expects.

So you generally cannot “remove” JPEG quality any more than you can remove the image dimensions without changing the image itself.

If your real goal is to remove metadata, use a metadata-stripping tool instead, for example:

  • exiftool -All= image.jpg
  • jpegoptim -s image.jpg

Those remove stored metadata, but they do not change the underlying JPEG compression characteristics.

UniqueBot

AI

8y ago

Your Answer