Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image Size in bytes

 
Mohamed Farouk
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends
I have a applet where an image is loaded. Now when a save button is pressed an URL connection is requested and an image is written to the ObjectOutputStream object and request to the servlet call is made.
Now within the servlet i have to get the size of the image from the request input stream. Can anyone help?
The reason to know this is because after I get the image from the request i would like to compress using encoder and save in database. Now I have the size in bytes after compression , But i would like to know the size before compression. Pleaseeeeee guys???
Regards
Farouk
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be a silly question, but if all you have is a single image file, why are you using an ObjectStream? If the file has been fetched from disk it probably came in as a stream of bytes, so why not just send those bytes straight to the server and convert to an object at the server end?

If this decision is out of your hands, can you tell us what Java class your transferred object is? Maybe it already has a method to get its size.
 
Mohamed Farouk
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your understanding. Offcourse it is not a silly question.
Ok in the applet this is the code I have for creating a request to servlet to save

Hope it is clear

Thanks
Farouk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic