RaceBase
RaceBase

Reputation: 18868

Converting Pixel Array to Image in Java

I have used this code to get Image into array of pixels.

Now I would like to convert the array of pixels to Image. But when I convert it, I am losing image data.

  1. Initial Image size: 80Kb JPG
  2. Duplicate Image size: 71Kb JPG

I can clearly notice some difference between the both images, the Java produced image has some sort of white-noise.

I would like to reproduce the image without single pixel loss of data, how do I achieve in Java?

Upvotes: 1

Views: 1203

Answers (1)

Joni
Joni

Reputation: 111389

The jpg file format uses a lossy compression algorithm which means that the files it generates will have slight differences from the original. You can change the quality setting to compress more or less but you can't save the with its original size without any modifications.

This is why jpg isn't recommended for image editing. Use a lossless format instead, like PNG.

Upvotes: 1

Related Questions