Inclusion of PNG in PDF without reencoding
Description
As evidenced by https://github.com/josch/img2pdf, it is possible to directly embed raw png data in pdf without decoding and re-encoding. This has some benefits
- Performance
- Smaller file sizes (possibly significantly so) when using optimized pngs (e.g. from https://github.com/oxipng/oxipng )
(Could also be relevant for some other formats if typst currently does not do so)
For JPEG, JPEG2000, non-interlaced PNG, TIFF images with CCITT Group 4 encoded data, and JBIG2 with single-page generic coding (e.g. using jbig2enc), img2pdf directly embeds the image data into the PDF without re-encoding it. It thus treats the PDF format merely as a container format for the image data. In these cases, img2pdf only increases the filesize by the size of the PDF container (typically around 500 to 700 bytes). Since data is only copied and not re-encoded, img2pdf is also typically faster than other solutions for these input formats.
Source: typst/typst