Menu

Image to byte[]

Anonymous
2017-08-31
2017-08-31
  • Anonymous

    Anonymous - 2017-08-31

    Is there a simple way to convert an Image to a byte[] without saving any file?
    I tried with

    ImageIO.write(ImageUtilities.createBufferedImage(output), "jpg", baos);
    

    but the result was an image with a high red drift.

     
  • Jonathon Hare

    Jonathon Hare - 2017-08-31

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageUtilities.write(output, "jpg", baos)
    byte[] bytes = baos.toByteArray();

     

Anonymous
Anonymous

Add attachments
Cancel