Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a unix command to check the level of compression or the compression ratio for an image (png,jpeg,gif)? The mac based mdls command displayed a lot of metadata information, but didn't mention anything about compression

share|improve this question

identify -verbose from imagemagick/graphicsmagick will tell you the image dimensions, number of channels and number of bits per channel.

From this you can derive how many bytes of memory the uncompressed image would take.

From this and the file size, you can determine how many bits-per-pixel it is compressing to.

share|improve this answer
Will: For a 1KB(1024 X 8 bits) image with a pixel count of 1890, the bits-per-pixel is "4.33". Is 4.33 the level of compression for this image? Is bits-per-pixel the indicator of compression? – smokinguns Apr 16 '12 at 18:00
@smokinguns: essentially "yes". a picture with WIDTHxHEIGHT pixels translates directly into MEMORYSIZE (WIDTH x HEIGHT x NUMBER_OF_CHANNELS x BITS_PER_CHANNEL). then look at the FILESIZE. COMPRESSION_RATIO = FILESIZE / MEMORYSIZE. a usual bits-per-pixel value is 24 or 32 (for RGB or RGBA pixels). – akira Apr 17 '12 at 9:01
isn't compression ratio the the size of the compressed file compared to that of the uncompressed file? I'm confused how bits-per-pixels can be an indicator of compression level. – smokinguns Apr 17 '12 at 17:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.