5 ms·
Fun with File Formats
- Lammy 5y agoIn addition to this resource and UK's equivalent (PRONOM/DROID, also mentioned in the linked post), I've found ArchiveTeam's wiki to be very useful for obscure file format details: http://fileformats.archiveteam.org/ http://fileformats.archiveteam.org/ The `shared-mime-info` database from freedesktop-dot-org is probably more worthy of contribution than these government-backed databases, at least in terms of number-of-end-users. New type definitions in their database will improve the entire Linux/BSD ecosystem (both desktop and server!) because it's consumed not only by fd.o's own `update-mime-database` utility but by many language-specific type-identification libraries too https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/data/freedesktop.org.xml.in https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/m... …including (shameless plug) the new Ractor-based Ruby type library I've been working on in the wake of the `mimemagic` drama earlier this year: https://github.com/okeeblow/DistorteD/tree/NEW%E2%80%85SENSATION/CHECKING%20YOU%20OUT https://github.com/okeeblow/DistorteD/tree/NEW%E2%80%85SENSA...
- pabs3 5y agoAlso the magic number database for guessing the format of a file: https://www.darwinsys.com/file/ https://www.darwinsys.com/file/
- alexott 5y agoThere is also Apache Tika (https://tika.apache.org/ https://tika.apache.org/) - file format detection & content extraction library
- Lammy 5y agoTika also stores its type definitions in the freedesktop format internally: https://gitbox.apache.org/repos/asf?p=tika.git;a=blob;f=tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml;h=e65b2691fbe66aa37c4eafc39cbb646f3e04195d;hb=HEAD https://gitbox.apache.org/repos/asf?p=tika.git;a=blob;f=tika... However their data is mostly focused on text/document types for obvious reasons :)
- cxr 5y ago> I've found ArchiveTeam's wiki to be very useful for obscure file format details: http://fileformats.archiveteam.org/ http://fileformats.archiveteam.org/ I took a serious look at trying to contribute to the Archive Team's "just fix the file format problem" effort a while ago. I ran into the problem that they require contributions be public domain/CC0. This prohibits material derived from the vast corpus of FOSS (even the most permissively licensed stuff—e.g. MIT, BSD, etc.) Considering how rare public domain/CC0 is, essentially everything would need to be done from scratch.
- kortex 5y agoYou should reach out to them and let them know. I don't know what the alternative would be - are there better CC licenses out there? Dual licensing CC+MIT/BSD? Pragmatically (but not legally speaking, INAL) you could probably get by with summarizing and linking (especially to web archive).
- TAForObvReasons 5y agoThere are two problems that reasonably explain the decision of only accepting public domain info: licensing and provenance. "Licensing" is hard. The "Open Specifications Promise" [1], which covers a bunch of Microsoft-designed file formats, is merely a covenant not to sue. "Provenance" is tricky. For example, much of the knowledge of the Apple iWork formats were derived by reverse-engineering the source programs and extracting protobuf definitions. Many open source projects have freely copied from each other, making detailed analysis tricky [2]. [1] https://en.wikipedia.org/wiki/Microsoft_Open_Specification_Promise https://en.wikipedia.org/wiki/Microsoft_Open_Specification_P... [2] https://github.com/jazzband/tablib/issues/114 https://github.com/jazzband/tablib/issues/114
- cxr 5y ago> There are two problems that reasonably explain the decision Boy do I hate these kinds of after-the-fact, speculative "explanations"—anachronistic rationalizations that come out of a mental exercise to justify what is by retroactively (and non-authoritatively) trying to invent a plausible why. And if you know the personality and values of the progenitor of the whole thing, then you know that this better-safe-than-sorry deference to hair-splittingly nuanced IP hurdles (that in practice don't really exist) is not the MO. Besides that, requiring public domain/CC0 doesn't solve either of those problems.
- deleted 5y ago[deleted]
- taubek 5y agoI wonder if there is some kind of way for software makers to provide all of the data to LOC? There is a lot of proprietary file formats that are in wide use. LOC has really done an amazing work.
- TAForObvReasons 5y agoThe software makers just need to write and release specifications in the public domain. Lotus did this many years ago with the 1-2-3 file formats: https://web.archive.org/web/20140713220544/http://www.schnarff.com/file-formats/lotus-1-2-3/WSFF1.TXT https://web.archive.org/web/20140713220544/http://www.schnar... The information contained in this document has been released into the public domain and is not considered to be confidential or proprietary although still the copyright and property of Lotus Development Corporation. Microsoft specifications are now covered by a "covenant not to sue", not really public domain. Apple doesn't even bother writing specs for their office suite
- taubek 5y agoI just came across specification for one new image format. https://twitter.com/phoboslab/status/1472916981179367425 https://twitter.com/phoboslab/status/1472916981179367425 It would be great if all of the new format were at least documented as this one.
- taubek 5y agoI guess by not providing the exact specs companies want to push customers towards their solutions. I also hate when you have the same software at multiple platforms but their proprietary file format is not compatible across all platforms.
- alexott 5y agoyeah, detection of file types is a fun. I worked on several implementation of very precise type detection (for use in email & web proxies), and there are so many low-level details that affect that detection. The biggest fun is detection of type for container-based file formats, like, OLE-based office files (office 95-2003), Zip-based formats (MS Office > 2003, OpenOffice/LibreOffice, jar/war/ear, ...) where you need to actually look into the file to determined the type. And to add complexity, the implementation should be very fast if you run inside the web proxy where type is detected for each request (at least twice for request/response stage, or more if you process an archive). Extraction of content is a separate fun ;-)
- nixpulvis 5y agohow does `file` stack up?
- alexott 5y agoFile was slower by at least 10 times slower (it was ~10 years ago). Second thing, for example it didn’t work with compound objects. Especially for things like word embedded in excel, etc. Similar for XML-based types, zip-based, … Plus rules aren’t very flexible - I’d used lisp-like language to describe detection patterns - that made it quite flexible in describing complex detection logic.
- kortex 5y agoAnyone else feel let down by all the existing container formats out there, and feel this itch to like, write their own? I know, I know, that's like the worst possible idea, xkcd #927 "now there are 15 standards", but like, what if? What I'm looking for is basically something that ticks all the boxes of LOC's 7 Sustainability Factors. Is able to store arbitrary binary data, along with metadata, in a single file. Easy to pack/unpack, particularly in Python. I'm pretty well covered for image/audio/video formats, but none of those lend themselves to n-dim arrays. Ogg, matroska, and HDF5 are all container formats which can ostensibly do this, possibly even well. Ogg and matroska are supposed to be able to support arbitrary data steams and metadata, but actually finding tooling to do the operations I want to do has yet to bear fruit. HDF5 is insanely complex, and I have some concerns about performance and data corruption risk. Tar is tempting but it does some really goofy things, like ending an archive with 1kB of zeros. What actually looks most promising as an existing "format" is the RIFF family of chunked encoding. Dead simple, python stdlib even has a reader. Only real downside is 2*32 ~= 4 gigabyte size limit, though this can be overcome by using a "stream of chunks" model. Alternatively, a stream based on Msgpack, with some slight constraints, is very appealing. Sqlite3, also very tempting. If I did write such a "format", it would definitely be built on the primitives of either RIFF, Msgpack, or Sqlite-as-application-file, so it'd be less of a "file format" and more of "existing format with some opinions about schema". Protip for anyone also thinking about making their own file format: make sure the API/format supports some sort of arbitrary metadata model! Apache Feather and Parquet are pretty recent, but don't really support writing metadata, you kind of have to hack around it. IMHO, this is a huge oversight, especially considering the internal metadata is literally just JSON-encoded fields. Edit: actually just reread the follow-up to "moving away from hdf5" and it mentions ASDF format. This looks really promising. YAML metadata header with binary blocks. Normally it's not a good idea to start with UTF8 and later go binary, but if you know when to stop reading text, it's not the worst. Also, it's a name collision with the asdf version manager (and also anything else named after rolling the left hand home keys) https://cyrille.rossant.net/should-you-use-hdf5/ https://cyrille.rossant.net/should-you-use-hdf5/ https://towardsdatascience.com/saving-metadata-with-dataframes-71f51f558d8e https://towardsdatascience.com/saving-metadata-with-datafram... https://en.m.wikipedia.org/wiki/Resource_Interchange_File_Format https://en.m.wikipedia.org/wiki/Resource_Interchange_File_Fo... https://msgpack.org/index.html https://msgpack.org/index.html https://www.sqlite.org/appfileformat.html https://www.sqlite.org/appfileformat.html https://asdf-standard.readthedocs.io/en/latest/ https://asdf-standard.readthedocs.io/en/latest/