Gwenview, and "Loading '.pnm' failed", and a clumsy solution

Apparently, Gwenview ver. 17.04.2 can’t handle .pnm files. Attempting to load them results in the error:

 Loading ‘Foo.pnm’ failed
Gwenview cannot display documents of type image/x-portable-anymap.


A quick search revealed nothing useful. However, on a whim, I removed the .pnm suffix from one file, after which the image loaded just fine.

For some reason, Gwenview chokes on the filename suffix itself. I consider the solution “clumsy” in that it’s only a workaround for the actual problem, and if you have a large number of such files to work with, you either need to rename them manually, or use a script. If it’s important to retain the filetype suffix information, simply removing the “.” would suffice. Also still clumsy.

So, I post this in case someone else trips over this problem. Hopefully I can save someone a hassle!

Wildcat

You do not explain how you try to let Gwenview handle them. IMHO there are two basic ways:

  1. click on the file (well, on a representation of the file in e.g. a file browser), where then the “file name associations” configuration of the the desktop (and you fail to tell which one you use) is involved;
  2. starting gwenview and using the "File " > “Open”.

In the first case changing that configuration might help.
(In my KDE, an old one, x-portable-anymap and the .pnm suffix are associated with GIMP only).

BTW what says

file Foo.pnm

.pnm is not a file format, it’s an name used for three distinct ones: PPM, PGM and PBM.
If you you remove the file extension, gwenview guesses the file type based on the contents, which works.
With the extension, it knows that it’s PNM, but as PNM is not a proper format itself it can’t open it.
As a better workaround, you can just use the proper extension, which is likely .ppm.

As “file -i <file>.pnm” is able to identify it correctly as “image/x-portable-pixmap”, it is probably a bug
in the mime magic with the priorities/strengths. I’m not an expert on that topic though.