How PNG Works: Compromising Speed for Quality

Reducible2 minutes read

PNG is a popular image format with lossless compression and uses filtering and LZSS algorithm for compression. QOI is a new image format that offers comparable compression to PNG but with faster encoding speeds, using run length encoding, difference encoding, and pixel indexing.

Insights

  • PNG utilizes advanced compression techniques like LZSS and modified Huffman coding for efficient image compression, enhancing quality while maintaining a balance between speed and file size.
  • The emerging image format QOI, although relatively new, offers comparable compression performance to PNG but distinguishes itself with faster encoding speeds due to its simplified approach of processing each pixel once and utilizing techniques like run length encoding and difference encoding, making it a promising alternative for image compression needs.

Get key ideas from YouTube videos. It’s free

Recent questions

  • What is PNG?

    A commonly used image file format for websites.

  • What is the new image format qoi?

    A faster alternative to PNG gaining popularity.

  • What is Huffman coding?

    A common scheme in lossless compression.

  • What is run length encoding?

    A method to compress sequences of similar pixel values.

  • How does QOI differ from PNG?

    QOI is faster with comparable compression performance.

Related videos

Summary

00:00

"Image File Formats: PNG vs JPEG"

  • PNG is a commonly used image file format that preserves image quality across websites.
  • JPEG compression can cause issues with vector graphics or text, unlike PNG.
  • PNG utilizes lossless compression, building on text compression algorithms like those in zip files.
  • A new image format called qoi is faster than PNG and gaining popularity.
  • Huffman coding is a common scheme in lossless compression, allocating fewer bits to more frequent data.
  • Huffman codes are generated by sorting pixel frequencies and building a Huffman tree.
  • Run length encoding compresses sequences of similar pixel values effectively.
  • Lempel Ziv schemes, like LZSS, handle repetitions of sequences better than Huffman coding.
  • LZSS involves back referencing to save space by referencing earlier sequences of characters.
  • PNG uses LZSS to represent pixels and offset length pairs for compression, with a filtering step to enhance compression by transforming pixel values.

17:02

"Efficient PNG and QOI image compression"

  • Filtering in PNG involves choosing the best pixel among three neighbors, subtracting it from the original pixel, and storing the value.
  • For RGB images, filtering is done individually on each channel to avoid mixing up red, green, and blue values.
  • To handle edge cases, out-of-bounds pixels are set to zero in PNG filters.
  • PNG selects the best filter for each row using the minimum sum of absolute differences heuristic.
  • PNG uses the LZSS algorithm to further compress the filtered image by replacing sequences of pixels with back references.
  • After LZSS, PNG employs a modified Huffman coding scheme to exploit remaining pixel redundancy.
  • QOI, a new image format, processes each pixel once for encoding, using run length encoding, difference encoding, and indexing of previously seen pixels.
  • QOI's simplicity lies in aligning all encoded bytes and using straightforward rules for encoding pixels.
  • QOI's compression performance is comparable to PNG, with significantly faster encoding speeds, making it a promising alternative.
Channel avatarChannel avatarChannel avatarChannel avatarChannel avatar

Try it yourself — It’s free.