From 53cb271c4b96699ad14a8b01b3e275ccfc091dcf Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 10 Nov 2019 22:10:49 +1100 Subject: [PATCH] Spin out a NIE Related Work document --- doc/spec/nie-related-work.md | 57 ++++++++++++++++++++++++++++++++++ doc/spec/nie-spec.md | 60 +++--------------------------------- 2 files changed, 61 insertions(+), 56 deletions(-) create mode 100644 doc/spec/nie-related-work.md diff --git a/doc/spec/nie-related-work.md b/doc/spec/nie-related-work.md new file mode 100644 index 00000000..a6a5a58f --- /dev/null +++ b/doc/spec/nie-related-work.md @@ -0,0 +1,57 @@ +# Naïve Image Formats (NIE, NII, NIA) Related Work + +This is a companion document to the [Naïve Image Formats (NIE, NII, NIA) +Specification](./nie-spec.md). Its contents aren't necessary for implementing +the NIE file format, but gives further context on what NIE is and is not. + +In general, being uncompressed, NIE/NII/NIA is not intended for long term +storage or for delivery over a network. Alternative lossless image formats like +[PNG](https://www.w3.org/TR/2003/REC-PNG-20031110/) or [WebP +Lossless](https://developers.google.com/speed/webp/docs/riff_container) are far +more suitable. + +Amongst uncompressed formats, [Farbfeld](https://tools.suckless.org/farbfeld/) +is a very similar design. The main difference is that NIE is little-endian (the +same as the vast majority of CPUs) where Farbfeld is big-endian. NIE/NII/NIA +also allows animated images, not just still images, and is also configurable +with respect to BGRA versus RGBA order, non-premultiplied versus premultiplied +alpha, and 8 versus 16 bit channels. Configurability is admittedly a trade-off: +one person's configuration parameter is another person's unnecessary bloat. +We're not saying that Farbfeld is a bad design, just a different design that +has chosen different trade-offs. + +[PAM](http://netpbm.sourceforge.net/doc/pam.html) (Portable Arbitrary Map) and +its related formats (PBM, PGM, PPM) are also very similar. The main difference +is that their headers are ASCII text and of variable length. Such headers are +easier for humans to read but harder for computers to parse. Again, NIE/NII/NIA +also allows animated images. Some programs process concatenated streams of PAM +images as an animation, but that doesn't contain explicit timing information. + +[VIPS](https://jcupitt.github.io/libvips/API/current/file-format.html) is the +intermediate format for the [libvips](https://libvips.github.io/libvips/) image +processing library. Pixel data is stored in a straightforward fashion, but +metadata is stored as XML, which is not simple, and is a potential security +concern. + +Amongst flexible formats, +[BMP](https://www.fileformat.info/format/bmp/egff.htm), +[PNG](https://www.w3.org/TR/2003/REC-PNG-20031110/) and its animated variant +[APNG](https://wiki.mozilla.org/APNG_Specification), +[Targa](http://tfc.duke.free.fr/coding/tga_specs.pdf) and +[TIFF](http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf) all have +their built-in compression being optional. Some of those uncompressed forms +have been used as simple interchange formats. Compared to those, NIE has fewer +features, which is obviously unfavorable if you want such features, but can be +favorable if you prefer simplicity and code auditability. A NIE file is still +simpler than an uncompressed BMP file and a NIA file is still simpler than an +uncompressed APNG file. + +For example, when using a sandboxed worker process to convert to an +intermediate format, we don't want to use "all possible valid TIFF images" as +the intermediate format, because a compromised worker process could generate a +malicious intermediate image that provoked a security bug in an unsandboxed +TIFF decoder. Instead, we would want only a very simple subset of TIFF, but it +can be easier (in terms of implementation and in terms of a code audit) to +write an (almost trivial) NIE parser from scratch instead of whittling down a +full-featured TIFF library and hoping that you've eliminated all the potential +security vulnerabilities. diff --git a/doc/spec/nie-spec.md b/doc/spec/nie-spec.md index aae049a0..4957a0a5 100644 --- a/doc/spec/nie-spec.md +++ b/doc/spec/nie-spec.md @@ -2,6 +2,9 @@ Status: Draft (as of August 2019). There is no compatibility guarantee yet. +A companion document has further discussion of [NIE related +work](./nie-related-work.md). + ## NIE: Still Images @@ -377,61 +380,6 @@ I pronounce "NIE", "NII" and "NIA" as "naɪ'i", "naɪ'aɪ" and "naɪ'eɪ", endi in a long "E", "I" or "A" sound. It's definitely a hard "N", not a soft one. -# Related Work - -In general, being uncompressed, NIE/NIA is not intended for long term storage -or for delivery over a network. Alternative lossless image formats like -[PNG](https://www.w3.org/TR/2003/REC-PNG-20031110/) or [WebP -Lossless](https://developers.google.com/speed/webp/docs/riff_container) are far -more suitable. - -Amongst uncompressed formats, [Farbfeld](https://tools.suckless.org/farbfeld/) -is a very similar design. The main difference is that NIE is little-endian (the -same as the vast majority of CPUs) where Farbfeld is big-endian. NIE/NII/NIA -also allows animated images, not just still images, and is also configurable -with respect to BGRA versus RGBA order, non-premultiplied versus premultiplied -alpha, and 8 versus 16 bit channels. Configurability is admittedly a trade-off: -one person's configuration parameter is another person's unnecessary bloat. -We're not saying that Farbfeld is a bad design, just a different design that -has chosen different trade-offs. - -[PAM](http://netpbm.sourceforge.net/doc/pam.html) (Portable Arbitrary Map) and -its related formats (PBM, PGM, PPM) are also very similar. The main difference -is that their headers are ASCII text and of variable length. Such headers are -easier for humans to read but harder for computers to parse. Again, NIE/NII/NIA -also allows animated images. Some programs process concatenated streams of PAM -images as an animation, but that doesn't contain explicit timing information. - -[VIPS](https://jcupitt.github.io/libvips/API/current/file-format.html) is the -intermediate format for the [libvips](https://libvips.github.io/libvips/) image -processing library. Pixel data is stored in a straightforward fashion, but -metadata is stored as XML, which is not simple, and is a potential security -concern. - -Amongst flexible formats, -[BMP](https://www.fileformat.info/format/bmp/egff.htm), -[PNG](https://www.w3.org/TR/2003/REC-PNG-20031110/) and its animated variant -[APNG](https://wiki.mozilla.org/APNG_Specification), -[Targa](http://tfc.duke.free.fr/coding/tga_specs.pdf) and -[TIFF](http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf) all have -their built-in compression being optional. Some of those uncompressed forms -have been used as simple interchange formats. Compared to those, NIE has fewer -features, which is obviously unfavorable if you want such features, but can be -favorable if you prefer simplicity and code auditability. A NIE file is still -simpler than an uncompressed BMP file and a NIA file is still simpler than an -uncompressed APNG file. - -For example, when using a sandboxed worker process to convert to an -intermediate format, we don't want to use "all possible valid TIFF images" as -the intermediate format, because a compromised worker process could generate a -malicious intermediate image that provoked a security bug in an unsandboxed -TIFF decoder. Instead, we would want only a very simple subset of TIFF, but it -can be easier (in terms of implementation and in terms of a code audit) to -write an (almost trivial) NIE parser from scratch instead of whittling down a -full-featured TIFF library and hoping that you've eliminated all the potential -security vulnerabilities. - - --- -Updated on August 2019. +Updated on November 2019.