28

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.)

  • 1
    Would image/* work (like browsers do)? – Boldewyn Sep 28 '15 at 12:29
  • @Boldewyn - image/*works for the purpose indicated in my question, even for svg files - that is, as a Desktop entry like MimeType=image/*. Please answer this more specific question to which you comment is the answer. – user162573 Sep 28 '15 at 12:53
26

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

  • Does it mean that there is a mime-type for multiple image files - not all, but many, so that it can be used for my purpose without the need of specifying the singular file extensions/mimes? – user162573 Sep 28 '15 at 9:36
  • 2
    @cipricus There is no single content-type/subtype that covers muliple image formats. – DavidPostill Sep 28 '15 at 9:41
  • @cipricus Answer updated to address your comment. – DavidPostill Sep 28 '15 at 10:00
  • as indicated in a comment under my question, image/*works for the purpose indicated in my question, even for svg files - that is, as a Desktop entry like MimeType=image/*. – user162573 Sep 28 '15 at 12:54
  • It may well work, but according to Desktop Entry Specification - "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." – DavidPostill Sep 28 '15 at 12:55
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy