wood burning stoves 2.0*
The moose likes Java in General and the fly likes Image IO problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Image IO problem" Watch "Image IO problem" New topic
Author

Image IO problem

Ravindra Harige
Ranch Hand

Joined: Jun 10, 2005
Posts: 33
Hello,

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 ]
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Originally posted by Ravindra Harige:
Sorry,i mis-edited my last post.please ignore the last(repeated) paragraph.

thanks,
Ravi


You can edit ( including delete ) the message using an icon at the top of the post that looks like a pencil and paper.

[ UD: removed parts that had nothing to do with the question, and which might be cause for confusion ]
[ April 16, 2008: Message edited by: Ulf Dittmer ]

"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41115
    
  45
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 - my free Android networking tools app
Ravindra Harige
Ranch Hand

Joined: Jun 10, 2005
Posts: 33
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.

thanks,
Ravindra
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41115
    
  45
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image IO problem
 
Similar Threads
append multiple jpg images to form multipage jpg Image
Uploading multiple image files
How can I merge 18 images to 1 images?
Is their a GUI app that can slice, dice ,and resassemble a JPG image on the screen?
single dimension array to multi dimension