I am using Java 5 on Windows 7.
I am converting a color JPEG to a grayscale JPEG using only classes from JDK.
Here are the relevant parts of my code:
After running my code, I open the image files using Windows Photo Viewer Here are some of the properties of the images as reported by Windows Photo Viewer Original (color)
Width = 1888 pixels
Height = 864 pixels
Horizontal Resolution = 300 dpi
Vertical Resolution = 300 dpi
Bit Depth = 24
File Type = JPG
File Size = 172 KB
I assume that the resolution of the grayscale image is 96 dpi because that is probably the resolution of my computer screen.
However, I don't understand why the file size is bigger for the grayscale image.
Please explain to me why the grayscale image's file size is so large compared to the original, color image's file size.
Yet again, I reply to my own post ;-)
Even if I don't convert the image to grayscale, i.e. simply read it and then write it, the resulting file is larger than the original.
This leads me to believe that the JDK's default JPEG writer is not optimal, i.e. other JPEG writers can compress images better.
Can someone perhaps point me to a better JPEG writer than that used by class "ImageIO" ?