Significant jpeg quality loss after downloading and base64 encoding
<p>My app downloads a Facebook user's jpeg profile picture and base64 encodes it. When decoding it, the resulting jpeg quality and size is significantly reduced. How do I avoid this?</p>

<p>Here is the way I'm downloading/encoding:</p>

<pre><code>// Download the profile picture.
BufferedImage image = ImageIO.read(new URL("http://facebook-profile-pic"));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(image, "jpeg", bos);

// Base64 encode it.
String imageData = new String(Base64.getEncoder().encode(bos.toByteArray()));
</code></pre>

<p>When I take the value of imageData and decode it, the image is way smaller than the one at the original download URL.</p>