[digiKam-users] JPEG grows bigger. Why?

Andrew Goodbody ajg02 at elfringham.co.uk
Sat Aug 7 22:31:03 BST 2021

On 07/08/2021 20:33, Dmitri Popov wrote:
> Hi Andrew,
> Thank you very much for your detailed reply.
>> But I suspect the most likely answer is that the original was saved at less than 100% quality.
> Just out of curiosity, how is that possible? I mean, if the original (let's call it IMAGE A) was saved with less than 100% quality, then some information would be inevitably discarded. Logically, saving IMAGE A at 100% shouldn't result in IMAGE B that is larger than IMAGE A. Because you can't have something more out of nothing. Am I making any sense?

But yes, you do get something more out of nothing. Except that it is not 
out of nothing, it is the result of expanding information saved in a 
lossy compression into a representation of the original image. Not 
everything in that original image was accurately described so the 
expanded image is a reconstruction that is close but not identical to 
the original image. But it has the same dimensions as the original.

Image A saved at 75% quality (some information lost, but still basically 
looks OK) but then expanded to be worked on gives you a working image 
that is the same dimensions as the original but the missing information 
is filled in with a best guess. This is how lossy compression works. 
Some information is lost but is replaced with a best guess based on the 
surrounding information (this is over simplified but good enough for here).
  You now save that as image B at 100%, this will now include a 
representation of the whole image including the parts that were filled 
in by best guess. So the added size is describing information that was 
not in image A. But when you reopen image B it will be a more exact 
representation of the image when saved.

You cannot edit jpeg data directly. You can only edit the expanded 
image. So when the expanded image is saved it is compressed again. You 
are not saving an edited version of the original compressed data, you 
are saving a compressed version of the edited image. Saving at a higher 
quality will take more data.


More information about the Digikam-users mailing list