Apache FileUpLoad and BufferedImage?

Posted on 2006-04-12
Last Modified: 2010-04-01

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);

   FileItem item = (FileItem);

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
Question by:AntoniRyszard
    LVL 27

    Expert Comment

    You can use.
    BufferImage bi =;

    Author Comment

    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%.

    LVL 27

    Accepted Solution

    Scaling can be done a number of ways  
    java.awt.geom.AffineTransform  has   scale(double sx,double sy)  
    java.awt.Image   has  getScaledInstance(int width,int height,int hints)

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

    Expert Comment

    >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  package.  
    Hopefully we will get some help from experts.  I am not real  expert in Image code.  

    Author Comment


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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    JTable - RowFilter & Columns Header. 3 129
    loop through list of objects 14 178
    reflection example 3 69
    instanceof  operator in java 26 54
    Outlook Free & Paid Tools
    This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now