Oct 30

Create a ByteArrayInputStream from your byte array and then use ImageIO class to read image from that stream.


InputStream in = new ByteArrayInputStream(bytearray);
BufferedImage image = ImageIO.read(in);

written by objects \\ tags: , , ,

One Ping to “How do I read an image from a byte array in Java?”

  1. η˜‹δΊΊι™’ι™’ι•·ι™’ε…§ζΆˆζ― » Daily Bookmarks 05/29/2010 Says:

    […] How do I read an image from a byte array in Java? | web development helpdesk […]


3 Responses to “How do I read an image from a byte array in Java?”

  1. djerry Says:

    this is really nice, been searching for it for quite a while

    all i saw where image from int[] arrays, but as i work with audio as well, i need byte[] arrays, so this is best way to do it, nice

  2. IsraUC3M Says:

    MAN YOU SAVED MY LIFE!!!

    Thanks a lot for this snippet!

  3. Namrata Says:

    Hey,
    This solution is worked well but when try to use same at google app engine, I’m not able to do.
    Google app engine doesn’t support BufferedImage or ImageIO
    I’m wondering about how it could be implemented.
    you can find the whitelist of GAE for JAVA at http://code.google.com/appengine/docs/java/jrewhitelist.html

    I’m having a webservice on which the image is passed as byte array from web client.

    Could you please suggest any way. Thanks in advance.

    Regards,
    Namrata Shah

Leave a Reply

You must be logged in to post a comment.