Comment 6 for bug 987641

Revision history for this message
Cameron White (cameronwhite91) wrote :

I did a bit more digging into this issue: when GDK tries to identify the mime type (http://git.gnome.org/browse/gdk-pixbuf/tree/gdk-pixbuf/gdk-pixbuf-io.c#n891), it somehow decides that TGA files created by Pinta have the mime type image/x-win-bitmap.

I tried other TGA files (such as from http://www.fileformat.info/format/tga/sample/index.htm) and Pinta was able to open them without any issue, and they are correctly identified as image/x-tga.

I think the issue happens because GDK looks at the file contents before the file extension, and the file contents generated by Pinta happen to look a lot like an ICO file. In particular, the first few bytes of Pinta's TGA files are the same as the expected first few bytes of an ICO file (see http://en.wikipedia.org/wiki/ICO_(file_format)).

A possible fix is to have a non-empty image ID field (http://en.wikipedia.org/wiki/Truevision_TGA#Header), with contents such as "Created by Pinta", since that would make the first byte non-zero. It's a bit of a hack, but I verified that it causes the file to be properly opened by Pinta. Thoughts?