Page 1 of 1

bug converting png to bmp (results in broken images)

Posted: 2018-08-06T14:52:39-07:00
by phildo
the most basic conversion of a simple png image to a bmp results in an image osx refuses to open (in preview, pixelmator, etc...). also, some hack software I wrote a while ago fails to open it, thinking it's a bmp v4 (it only accepts bmp v5) (this pipeline used to work on older versions of imagemagick, or osx, or some combo).

the command I use is

Code: Select all

convert 0.png ~/Desktop/0.bmp
png used is Image
bmp result is Image

Code: Select all

convert --version
yeilds

Code: Select all

Version: ImageMagick 7.0.8-8 Q16 x86_64 2018-07-23 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
using macos high sierra (10.13.6)

Re: bug converting png to bmp (results in broken images)

Posted: 2018-08-06T14:54:25-07:00
by phildo
hmm... I now see that chrome correctly renders the bmp in chrome when served from my web site. but if I save-as that image to my desktop, OSX refuses to open it.

Re: bug converting png to bmp (results in broken images)

Posted: 2018-08-06T15:35:55-07:00
by fmw42
It fails for me also on Mac Sierra with IM 6.9.10.9 Q16 and 7.0.8.9.

This will not open:

Code: Select all

convert 0.png 0.bmp
These two produce black results:

Code: Select all

convert 0.png BMP3:0.bmp
convert 0.png BMP2:0.bmp
Perhaps it is the transparency in the PNG. The PNG is bilevel with 8-bit transparency. This may be a PREVIEW problem not being able to handle bilevel bmp with 8-bit transparency.

I can open it fine on my Mac in GraphicConverter. However, Photoshop gives only a black image

I have limited understanding of BMP format and only know from https://www.imagemagick.org/Usage/formats/#bmp

Re: bug converting png to bmp (results in broken images)

Posted: 2018-08-07T07:49:56-07:00
by phildo
I found a workaround-

Code: Select all

convert 0.png PNG32:0.png
convert 0.png 0.bmp
produces a functional bmp (renders/opens on osx, including the bespoke software I had that only accepted a rigid bmp format).

I think the problem was that the png was considered grayscale + alpha. so the "real" bug here is:

"convert fails to convert grayscale pngs to bmps"

Re: bug converting png to bmp (results in broken images)

Posted: 2018-08-08T16:20:49-07:00
by magick
The conversion appears to be working properly. It creates a BMP v4 image. Some viewers may not properly handle BMP v4 images. We did check with a few BMP viewers and half of them returned expected results and half failed and returned a black image.