This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Image corruption Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Image corruption" Watch "Image corruption" New topic

Image corruption

Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
I do not have much experience in image manipulation. I am trying to take an upload from webapp place into the database and retrieve with a servlet (which dynamically resizes the image). Everything works except sometimes the image, which are all jpg, turn grey halfway through the drawing process. Since this occurs no matter how the image is dynamically sized, I can only assume that it is being stored in the db that way during the upload. Could someone browse through my code and see if there is anything that would cause this?

BTW, getInputStream() is called on a struts FormFile, so that shouldn't be the problem.
SCJP 1.4
Joe Ess

Joined: Oct 29, 2001
Posts: 9191
    9 returns a BufferedImage, so there's no need to "convert".
I don't see anything else obvious here. You should try writing the image out to a file before resizing it. Then you can see if your problem is on the input or output side.

[How To Ask Questions On JavaRanch]
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
BTW, I solved the problem!

The column that I am storing it in was a BLOB, which only holds 16KB. I changed to MEDIUMBLOB with holds 16MB. Thanks for the help.
I agree. Here's the link:
subject: Image corruption
It's not a secret anymore!