mime.types(5)
๐ mime.types โ the vibe-coded file-type decoder ring ๐
okay bestie, sit DOWN, because this is mime.types(5), a manual page from OpenPrinting all about the CUPS mime type description file, and honestly? it's giving "quietly runs your entire printing pipeline" and I'm obsessed ๐
โจ NAME โจ
mime.types โ the mime type description file for cups, aka the little text file that tells CUPS what all your files actually are ๐ฆ
๐ธ DESCRIPTION ๐ธ
so the mime.types file is literally where the recognized file types live. that's it. that's the whole job. ๐
and if you want MORE file types? no problem, because extra ones get specified in files with the .types extension sitting inside the CUPS configuration directory. slay.
every single line in mime.types is one of three things: a comment, a blank line, or a rule line. comment lines start with the # character (yes, the humble hashtag, iconic). rule lines start with the MIME media type and are optionally followed by a series of file recognition rules:
mime/type [ rule ... rule ]
and if your rule is really-really-really long? bestie you can extend rules over multiple lines using the backslash character (\):
mime/type [ really-really-really-long-rule ... \
rule ]
the MIME media types you specify in that mime/type field are case-insensitive, and they get sorted in ascending alphanumeric order for the purposes of matching. want the whole tea? peek at the "TYPE MATCHING AND PRIORITY" section below, it's all there ๐
also you can group rules using parenthesis, join them using + for a logical AND, join them using , or whitespace for a logical OR, and negate them using !. logic gate era fr fr ๐ฅ
๐ง RULES ๐ง
rules come in two forms โ a filename extension all by itself, and functions with test values inside parenthesis. here's every function you get, no gatekeeping:
match("pattern")โ true if the filename matches the given shell wildcard pattern. classic. reliable. we stan. โญascii(offset,length)โ true if thelengthbytes starting atoffsetare valid printable ASCII (CR,NL,TAB,BS,32-126). and heads up:lengthcannot exceed 8192 bytes. no cap, that's the limit ๐ซถprintable(offset,length)โ true if thelengthbytes starting atoffsetare printable 8-bit chars (CR,NL,TAB,BS,32-126,128-254). same rule though:lengthcannot exceed 8192 bytes ๐priority(number)โ specifies the relative priority of this MIME media type. the default priority is100. larger values have higher priority while smaller values have lower priority. it's giving ranked choice voting ngl ๐string(offset,"string")โ true if the bytes starting atoffsetare identical tostring. exact match energy.istring(offset,"string")โ true if the bytes starting atoffsetmatchstringwithout respect to case. the chill, case-insensitive twin ofstring๐char(offset,value)โ true if the byte atoffsetis identical tovalue.short(offset,value)โ true if the 16-bit big-endian integer atoffsetis identical tovalue.int(offset,value)โ true if the 32-bit big-endian integer atoffsetis identical tovalue.locale("string")โ true if current locale matchesstring. hometown pride but for locales ๐contains(offset,length,"string")โ true if the bytes starting atoffsetforlengthbytes containsstring. and yes,lengthcannot exceed 8192 bytes. same ceiling, every time ๐
๐ STRING CONSTANTS ๐
string constants can be specified inside quotes ("") for strings containing whitespace, and angle brackets (<>) for hexadecimal strings. pick your fighter ๐
๐ TYPE MATCHING AND PRIORITY ๐
when CUPS needs to determine the MIME media type of a given file, it checks every MIME media type defined in the .types files. when two or more types match a given file, the type chosen will depend on the type name and priority โ with higher-priority types being used over lower-priority ones. and if the types have the same priority? the type names are sorted alphanumerically in ascending order and the first type is chosen. tiebreaker arc ๐ญ
for example, if two types "text/bar" and "text/foo" are defined as matching the extension "doc", normally the type "text/bar" will be chosen since its name is alphanumerically smaller than "text/foo". however, if "text/foo" also defines a higher priority than "text/bar", "text/foo" will be chosen instead. plot twist, but make it deterministic โจ
๐ FILES ๐
/etc/cupsโ Typical CUPS configuration directory.
๐ EXAMPLES ๐
define two MIME media types for raster data, with one being a subset with higher priority:
application/vnd.cups-raster string(0,"RaSt") string(0,"tSaR") \
string(0,"RaS2") string(0,"2SaR") \
string(0,"RaS3") string(0,"3SaR")
image/pwg-raster string(0,"RaS2") + \
string(4,PwgRaster<00>) priority(150)
see how the second one is out here using + for AND and flexing that priority(150)? main character behavior, honestly ๐ฅ
๐ SEE ALSO ๐
cups-files.conf(5), cupsd.conf(5), cupsd(8), cupsfilter(8), mime.convs(5), CUPS Online Help (http://localhost:631/help)
go read them, bestie, the whole cinematic universe is connected ๐ฆ
๐ COPYRIGHT ๐
Copyright ยฉ 2020-2024 by OpenPrinting.
okay that's the whole page, no notes ๐ lowkey this one ate and left no crumbs. iykyk ๐
and that's a wrap on the CUPS era, bestie โ this page came straight out of the 2021-02-28 release of CUPS (the OpenPrinting edition, obviously ๐). go forth and correctly identify your file types, you absolute icon ๐
โจ๐ธ
๐ฆ where this page comes from
- alpine 3.22: cups-doc 2.4.18-r0 ยท Apache-2.0
- alpine 3.23: cups-doc 2.4.18-r0 ยท Apache-2.0
- alpine 3.24: cups-doc 2.4.19-r1 ยท Apache-2.0
- centos-stream 10: cups 1:2.4.10-18.el10 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- debian trixie: cups-daemon 2.4.10-3+deb13u1 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- debian trixie: cups-daemon 2.4.10-3+deb13u2 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- fedora 43: cups 1:2.4.14-2.fc43 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- fedora 43: cups 1:2.4.19-3.fc43 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- fedora 44: cups 1:2.4.16-7.fc44 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- fedora 44: cups 1:2.4.19-3.fc44 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- nixpkgs unstable: cups 2.4.19
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- ubuntu questing: cups-daemon 2.4.12-0ubuntu3
- ubuntu questing: cups-daemon 2.4.12-0ubuntu3.10
- ubuntu resolute: cups-daemon 2.4.16-1ubuntu1 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- ubuntu resolute: cups-daemon 2.4.16-1ubuntu1.3 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- ubuntu stonking: cups-daemon 2.4.16-1ubuntu3 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- Copyright ยฉ 2020-2024 by OpenPrinting
- Copyright ยฉ 2007-2019 by Apple Inc
- Copyright ยฉ 1997-2006 by Easy Software Products
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms