Is there a generic mime-type for all image files?
I know that I can use the specific mime-types as listed for example here, or a generic mime-type for any file like application/octet-stream
, but is there a generic mime-type for all image files?
(I want to edit a .desktop
file in Linux Mint KDE to create an 'Action' context-menu entry in Dolphin File Manager that would be shown only for image files.)
Is there a generic mime-type for all image files?
Normally there isn't, but there are a couple of exceptions documented later in this answer.
You need a Mime Type in order to know how to process a file (without having to read the file header).
Notes:
-
Not all image files have a header that identifies their type.
-
SVG files, for example, are just XML files. So without the correct mimetype or extension there would be no way to correctly identify the type of the file.
-
Mime Types are specified as Content-Type/subtype
-
There isn't a Mime Type
image/generic
(See "Further reading" below for the full list of IANA registered image subtypes).
Does it mean that there is a mime-type for multiple image files?
There is no single Content-Type/subtype
that covers multiple image formats.
In theory you could use an unknown Subtype such as image/xyz
but W3C says explicitely:
"a Content-Type of image/xyz
is enough to tell a user agent that the data is an image, even if the user agent has no knowledge of the specific image format xyz
... "such an action might be reasonable for unrecognized subtypes of text, but not for unrecognized subtypes of image or audio"
In general, the top-level Content-Type is used to declare the general type of data, while the subtype specifies a specific format for that type of data.
Thus, a Content-Type of "image/xyz" is enough to tell a user agent that the data is an image, even if the user agent has no knowledge of the specific image format "xyz".
Such information can be used, for example, to decide whether or not to show a user the raw data from an unrecognized subtype -- such an action might be reasonable for unrecognized subtypes of text, but not for unrecognized subtypes of image or audio.
For this reason, registered subtypes of audio, image, text, and video, should not contain embedded information that is really of a different type. Such compound types should be represented using the "multipart" or "application" types.
Source W3C - The Content-Type Header Field
Can I use a wildcard like image/*
for my special case?
so that it can be used for my purpose without the need of specifying the singular file extensions/mimes?
Yes. As you have pointed out a wildcard can be used when specifying the "Desktop Entry" for the the KDE and GNOME desktop environments.
However, please note that Key=MimeType
is deprecated as there is a new standard for this.
Type=MimeType
is deprecated as there is a new standard for this now, see the Shared MIME-info Database specification for more information. In consequence the Keys Patterns (various file name extensions associated with the MIME type) and DefaultApp (the default application associated with this MIME type) are also deprecated.
Source Desktop Entry Specification
You can also use wildcards for mime types in IIS, but is advised to not do this:
You can also configure IIS to serve undefined file types by adding a wildcard character (*) MIME type.
Do not use wildcard MIME-types on production servers. Doing so can result in IIS serving unrecognized files and displaying sensitive information to users.
Wildcard MIME-types are intended for testing purposes or in scenarios where Internet Server API (ISAPI) filters have been developed specifically to handle these wildcard scenarios, for example, a custom authentication ISAPI.
Source Creating Global MIME Types
Further reading
- IANA - Registered Media Types - Image (Image Content-Type and subtypes)
- W3C - The Content-Type Header Field
According to this SO-Answer there is no generic MIME-Type. The problem is that the MIME-Type is allways composed of a Type, a Subtype and a optional Parameter: Type/Subtype; Parameter
(see here). You only want to use the type, but by definition a subtype is required and there is no generic subtype. A list of all image types can be found here.