bug converting png to bmp (results in broken images)

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
phildo
Posts: 3
Joined: 2018-08-06T14:43:00-07:00
Authentication code: 1152

bug converting png to bmp (results in broken images)

Post 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)
phildo
Posts: 3
Joined: 2018-08-06T14:43:00-07:00
Authentication code: 1152

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
phildo
Posts: 3
Joined: 2018-08-06T14:43:00-07:00
Authentication code: 1152

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

Post 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"
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
Post Reply