"Unrecognised or invalid BMP compression format" error message
GIMP version: 2.10.22
Operating System: Linux Mint 20
Package: Flatpak
Description of the bug
GIMP fails to create 24-bit BMP files with included colour space information correctly.
Reproduction
Is the bug reproducible? Always
Open GIMP
"File/New/OK"
"File/Export As..."
Select file type as Windows BMP image
"Export"
Leave "Compatibility Options/Do not write colour space information" unchecked (so that this information is written to the file)
In "Advance Options" select 24-bits R8G8B8 (which is the default) "Export"
Close GIMP
Now try opening the file with GIMP - it displays the message "Unrecognised or invalid BMP compression format."
Other applications (xviewer and pix for example) also fail to open this file.
Expected result: GIMP opens the file successfully.
Actual result:
The error message noted above is displayed.
Additional information
GIMP can save BMP files in the following formats with or without colour space information:
16-bit R5G6B5, A1R5G5B5 and X1R5G5B5
24-bit R8G8B8
32-bit A8R8G8B8 or X8R8G8B8
All formats seem to work when saved without colour space information and all formats apart from the 24-bit one work when colour space information is included.
When colour space information is included the files include a BITMAPV5HEADER (as shown by the byte at offset 0x0E being set to 0x7C (124.).
The problem would appear to be with the Compression field which starts at offset 0x1E. For all of the BMP files saved by GIMP with colour space information included the byte at offset 0x1E us set to 0x03 - the Microsoft specification for BITMAPV5HEADER says that this setting is valid for 16 and 32-bits per pixel files - by implication it is not valid for files with 24-bits per pixel. Using a hex editor to change the value of the byte at offset 0x1E from 0x03 to 0x00 allows tha file to be opened successfully by GIMP and by the other applications that I tried that would not previously open the file.
I'm not sure whether there are other changes required to fix this properly (i.e. changing the setting of this byte just appears to work but there is another less obvious problem) but it certainly allows such files to be accessed.
It is perhaps ironic that using the default settings GIMP produces a file that not even it will open!