JDK-4972087 : Quality Desc and Quality Values arrays are of same length for JPG
  • Type: Bug
  • Status: Closed
  • Resolution: Fixed
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Priority: P4
  • Affected Version: 1.4.0
  • OS: generic
  • CPU: generic
  • Submit Date: 2003-12-23
  • Updated Date: 2006-12-06
  • Resolved Date: 2005-10-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
6 b56Fixed
The API specification for getcompressionQualityDescriptions() claims that the array length of the compression quality values returned by the ImageWriteParam must always be one greater than the array length of quality descriptions returned by the same write param for any image format. This does not work for JPG. For JPG, both the arrays returned are of same length.

This is reproducible right from JDK1.4 on all the platforms.

I have attached a sample code. Execute the sample code and watch the console. If the array length of quality desc and quality values are same then the bug is reproduced.
###@###.### 2003-12-23

Attached the testcase.

###@###.### 2003-12-23

EVALUATION The problem is that when the JPEGImageWriteParam code was written, it was assumed that the compression quality values have a one-to-one mapping to the compression quality descriptions. But with a careful reading of the ImageWriteParam spec, it is noticed that the descriptions should refer to a range of values. (So vals.length should be descs.length+1...) Since the existing descriptions match specific values, we thought it would be good to change the descriptions and values slightly to fit: "Low quality", // 0.00 -> 0.30 "Medium quality", // 0.30 -> 0.75 "Visually lossless" // 0.75 -> 1.00