File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Image Size in bytes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Image Size in bytes" Watch "Image Size in bytes" New topic
Author

Image Size in bytes

Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 249
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


SCJP, SCWCD, SCBCD, SCEA 5
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 249
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image Size in bytes