The following code reads a jpg image into an int array and writes the same pixel array without any modification to a jpg file
here i was expecting the quality and size of the output image same as of input image but the quality of image is poor and the size is also less than that of input image.why is it so,when im not modifing the pixels of input img? secondly,if i am changing the output image format to bmp(#2),the output image retains the quality of original one but size of output image becomes very large.
is there any way by which i can read and write the same image without any modification and get the output image of same quality and size as that of input image??
Regards, Ravi [ April 16, 2008: Message edited by: Ravindra Harige ]
The JPEG format contains an advanced compression technique, which can makes images comparatively smaller than other formats (like BMP).
JPEG also has built-in quality settings that allow you to trade off file size for image quality. My guess would be that the default quality is not set to 100% (which would preserve the image in full). This code example shows how to use the ImageIO JPEG quality settings.
Ping & DNS - updated with new look and Ping home screen widget
Joined: Jun 10, 2005
Thanks Ulf for pointing to the sample code.It writes the jpg file with same quality as of the original one (given compressionquality=0.0f). but the integer pixel array of input file and output file differed when compared.
Actually,i wanted to - read a jpg image into integer pixel array, - write it to a jpg file without modifying pixel array (such that output jpg file preserves the quality of input image and the size of output image is almost same as input file) - again read the output image into pixel array such that pixelarray(input_image) = pixelarray(output_image)
I am stuck on the last point.please help me out.
Joined: Mar 22, 2005
I'm not sure if that's possible; I think it isn't. JPEG is not a good format to use if you need to preserve pixel values. PNG is a better choice.