Quantcast
Channel: web development helpdesk » image
Viewing all articles
Browse latest Browse all 10

How do I convert a Java image to a jpeg encoded byte array?

$
0
0
The ImageIO class can be used to write an image as a JPEG encoded stream.If you write that stream to a ByteArrayOutputStream then you will end up with a byte array that contains the JPEG encoded image. ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(image, "JPEG", out); byte[] imageBytes = out.toByteArray();

Viewing all articles
Browse latest Browse all 10

Trending Articles