Page 1 of 1

BMP distorted when viewing/converting

Posted: 2012-02-17T09:30:29-07:00
by kovidgoyal
The following BMP file is distorted when viewing with display or converting with convert to png. It views correctly in firefox and gwenview (which uses the Qt image reading plugins). ImageMagick 6.7.5.3 on 64bit linux.

http://kovidgoyal.net/test.bmp

When converted by ImageMagick to png with convert test.bmp test.png it looks like:

http://kovidgoyal.net/test.png

The image appears to have been wrapped around the canvas. The same bmp image display correctly with either Qt or firefox.

Thanks.

Re: BMP distorted when viewing/converting

Posted: 2012-02-17T15:09:22-07:00
by magick
With bmptoppm we get
  • bmptoppm: Windows BMP, 300x500x8
    bmptoppm: warning: the BMP header says the raster starts at offset 40 bytes into the file (offbits), but that there are 1078 bytes of information before the raster. This inconsistency probably means the input file is not a legal BMP file and is unusable.
    bmptoppm: broken.bmp: read error
If we override the BMP offbits of 40 and set it to 1078, we get the expected results.

It appears your image is corrupt. Do you have any reason to believe otherwise?

Re: BMP distorted when viewing/converting

Posted: 2012-02-17T21:02:45-07:00
by kovidgoyal
It's generated by Microsoft Word and is correctly interpreted by: Word, wordpad, openoffice, firefox, gwenview (any program based on the Qt toolkit). It is incorrectly interpreted by imagemagick, bmptoppm and gimp. It may well be corrupted, given that it's a Microsoft format, I'd say its natural state is to be corrupted, but lots of programs accept it and display it correctly. Whether you wish to do so in ImageMagick is entirely up to you, of course :)

Re: BMP distorted when viewing/converting

Posted: 2012-02-17T22:14:49-07:00
by fmw42
For what it is worth, I can display it on my Mac OSX Snow Leopard in Photoshop CS3 but it is wrapped like the png image. Mac Preview says it is corrupt and won't display it. However, GraphicConverter displays it correctly.