[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Apache FileUpLoad and BufferedImage?

Posted on 2006-04-12
5
Medium Priority
?
458 Views
Last Modified: 2010-04-01
Hello,

I am planning to use the apache fileupload tool, to access images posted to a servlet.

The servlet accesses the files using:

List items = upload.parseRequest(req);

while(iter.hasNext()){
   FileItem item = (FileItem) iter.next();
}

My plan was to create a thumbnail of the orginal image, and this and orginal image.

Could anyone advise if I could possibly create an BufferedImage object or Image object from the item variable above, and then reduce the image size using the bufferedimage?

Thank you
0
Comment
Question by:AntoniRyszard
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 16439253
You can use.
BufferImage bi = ImageIO.read(item.getInputStream());
0
 

Author Comment

by:AntoniRyszard
ID: 16439348
Thanks I'll try this,

Do you think this would work for gif and png images as well?

Could you offer any advise in creating an thumbnails from the orginal.

I thought it would be difficult to make all the thumbnails one size automatically. Perhaps I should take a width, height of the orginal image and determine from this if I should scale down by 50%, 25%.

Thanks
0
 
LVL 28

Accepted Solution

by:
rrz earned 220 total points
ID: 16439360
Scaling can be done a number of ways  
java.awt.geom.AffineTransform  has   scale(double sx,double sy)  
or  
java.awt.Image   has  getScaledInstance(int width,int height,int hints)

I don't which one the experts are using.  What formats ?  jpg ?
0
 
LVL 28

Expert Comment

by:rrz
ID: 16439547
>Do you think this would work for gif and png images as well?
Are you using Java 5 ?  
ImageIO has readers for jpg, png, and gif .  Writers for   jpg and png,  I am not sure about gif. You might have to use Acme.com  package.  
Hopefully we will get some help from experts.  I am not real  expert in Image code.  
0
 

Author Comment

by:AntoniRyszard
ID: 16439624
Thanks

I am not very use to the Image or AffineTransform classes. I will look into these.

Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question