1

Is there a way to convert a Java Image, encode it into JPEG (but not saving it to a file), and store it as an array of bytes? (byte[]) I need the JPEG-encoded image as an array of bytes.

1 Answer 1

4

ImageIO has a number of methods for reading and writing images.

For writing to array of bytes, you can write to ByteArrayOutputStream. And then call toByteArray[] of the stream object to obtain the byte array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.