Gautham J Gautham J - 1 year ago 141
Python Question

Png and Jpeg of PIL

When I create a random image having just white and black dots using random function for determining whether a particular pixel is black or white and it is done in a 1 bit depth
And I save that image in Jpeg
Using the command"myjmage.jpg","JPEG")

Also I save the same image"myimage.png","PNG")

When I checked the sizes png is 6 mb and jpg is 36 mb
So doubt I have read that png is a lossless compression and Jpeg is not . Then how is this possible? Jpeg having greater size than png ? What am I missing here !?

The image is of 10000*10000 pixels

Answer Source

JPEG is using 8 bits per sample while PNG is using 1 bit per sample, for black-and-white images, before compression. So even though JPEG compression is generally more effective than PNG's lossless compression, in your tests PNG has an 8 to 1 head start.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download