0

I am trying to get the quality of an image using Java and I am having a hard time to find any API that would do that.

I stumbled upon the ImageMagick command identify which works great but I would like to know if there is a Java API that would do something similar.

Here is ImageMagick command that I found

How can I get the quality of an image using Java?

M. Justin
  • 14,487
  • 7
  • 91
  • 130
Shriram Sharma
  • 599
  • 1
  • 5
  • 19
  • Voting to reopen. Looking at the question, it doesn't look like it's specifically a library request, but rather a request to solve a problem using Java (which may or may not need an external library to solve). I updated the title to make this more clear. This question seems to completely OK based on this explanation of how to avoid asking a "recommendation" question: https://meta.stackoverflow.com/a/254394/1108305. – M. Justin Dec 11 '20 at 19:47

2 Answers2

1

The ImageMagick website has a page that lists APIs for numerous programming languages, including Java. These can be used to get the quality from within a Java program.

The two listed Java libraries are JMagick and Im4java:

JMagick provides an object-oriented Java interface to ImageMagick. Im4java is a pure-java interface to the ImageMagick command-line.

Note that the JMagick link appears to be broken. A web search suggests that the htechblue/jmagick fork on GitHub is a more recently maintained replacement.

Either of these libraries should work for accessing the quality from within a Java program.

M. Justin
  • 14,487
  • 7
  • 91
  • 130
1

To calculate the compression of an image you can compare the actual file size to the size you'd get if you were storing the image "raw".

For example a jpeg file that's 1024x1024, true color (24bpp) that's 384Kb you'd get a ratio of (384x1024) / (1024x1024x3) = 0.125, this means the jpeg produced a file that's 12% of raw image.

No need to uncompress the image.

C. Miller
  • 31
  • 3