The way that PNGs do transparency is that they have 4 “color layers” – one for red, green, blue and “alpha”
Red green and blue channels are enough to be combined to make the color for each pixel. The alpha channel indicates for each pixel, “how transparent” it should be
JPG only has the red/green/blue channels, so it doesn’t support transparency
An older format, GIF, supports transparency but only as a binary on/off value, i.e. the pixel is either fully opaque or full transparent
To put it kind of redundantly, PNG can support transparency (technical term, Alpha) and JPEG cant simply because both standards are designed to be that way.
JPEG (Joint Photographic Experts Group) is intended for use with realistic images captured off a camera. So it supports the Red/Green/Blue channels and has lossy compression which is fine with natural images with realistic gradients in tone between pixels. It doesn’t support an Alpha channel because its just not how the format was intended to be used.
PNG (Portable Network graphics) was originally intended to replace GIF when it was realized the compression algorithm used by that actually demanded royalties to be paid to a private company. So it was meant to replace GIF, which nowadays is used near exclusively for its animation capabilities but was more common as a still image back then. GIF does support a binary Alpha channel (The pixel is fully transparent or fully opaque) and so PNG inherited Alpha support, if at far greater quality than GIF allowed as with its colour information.
As a sidenote, as an animator and graphic designer, GIF is a terrible format that has literally received no revisions since 1989, the internet really needs to collectively move on to a new standard.
Latest Answers