Bug: BMP are 32 bit should be 24 bit NOT TrueColorMatte
Posted: 2007-02-22T00:15:04-07:00
Hi,
This is my first post and I am a new user of Image Magick. I have done a lot of thrashing around and at this point am pretty sure it is a bug in IM/MagicWand rather than an error in my code. I was going to file this under the PHP section but in my search for answers I found that someone using TCL had a similar problem.
Summary: MagicWand_PHP produces invalid BMP files
Despite any settings that I make when saving the image, the ImageType is always "TrueColorMatte", which is not valid. The ImageType should be "TrueColor".
Version:
Even after all of that the result is:
This bug is important because it prevents you from being able to create printable images.
Eventually I found this article by Phillip Perkins which uses the same technique of printing a BMP that I was trying to use, and it obviously worked for him -- see listing "A" in His Article It's because of his article that I am certain this is a bug. I also found a TCL article discussing a similar problem with MagicWand creating 32 bit BMP.
As far as I know, Windows does not support transparent BMP, this is not a valid format. What I find is that on XP, mspaint.exe will open the file without complaint. However, GIMP complains of an invalid header and php printer_draw_bmp() rejects the BMP.
After much much thrashing around I find no way at all using MagicWand to create a 24 bit BMP. But from the command line, this works fine.
I found that command in an email thread where someone was saying they were unable to convert a gif into a 24 bit BMP. So, even from the command line it appears that there is a problem, but at least there is a way to fix/work-around it at that level.
Expected:
Thank You for creating such a Wonderful Program!
-- Erik
~
This is my first post and I am a new user of Image Magick. I have done a lot of thrashing around and at this point am pretty sure it is a bug in IM/MagicWand rather than an error in my code. I was going to file this under the PHP section but in my search for answers I found that someone using TCL had a similar problem.
Summary: MagicWand_PHP produces invalid BMP files
Despite any settings that I make when saving the image, the ImageType is always "TrueColorMatte", which is not valid. The ImageType should be "TrueColor".
Version:
- ImageMagick-6.3.2-6-Q16-windows-dll.exe
- php5.2_magickwand_dyn.dll
- php 5.2
Code: Select all
Example: PHP
$x_resolution = $y_resolution = 300;
$im_cols = 4 * $x_resolution;
$im_rows = 3 * $y_resolution;
$MagickWand = NewMagickWand();
$status = MagickSetImageType($MagickWand, MW_TrueColorType);
$status = MagickSetImageColorspace($MagickWand, MW_RGBColorspace);
$status = MagickSetImageDepth($MagickWand , 8, MW_AllChannels);
$status = MagickSetImageFormat($MagickWand, "bmp");
$status = MagickSetResolution($MagickWand, $x_resolution, $y_resolution );
$status = MagickNewImage($MagickWand, $im_cols, $im_rows, "#ffffe0");
//draw some text.... "DrawAnnotation"
//set the properties again
$status = MagickSetImageDepth($MagickWand, 8);
$status = MagickSetImageType($MagickWand, MW_TrueColorType);
$status = MagickSetImageFormat($MagickWand, "BMP");
$status = MagickWriteImage($MagickWand, "c:/tmp/bad.bmp");
Even after all of that the result is:
Code: Select all
identify -verbose bad.bmp
Image: bad.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 2976x3876+0+0 (Note: the example above uses different dimensions)
Type: TrueColorMatte
Endianess: Undefined
Colorspace: RGB
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit
This bug is important because it prevents you from being able to create printable images.
Eventually I found this article by Phillip Perkins which uses the same technique of printing a BMP that I was trying to use, and it obviously worked for him -- see listing "A" in His Article It's because of his article that I am certain this is a bug. I also found a TCL article discussing a similar problem with MagicWand creating 32 bit BMP.
As far as I know, Windows does not support transparent BMP, this is not a valid format. What I find is that on XP, mspaint.exe will open the file without complaint. However, GIMP complains of an invalid header and php printer_draw_bmp() rejects the BMP.
After much much thrashing around I find no way at all using MagicWand to create a 24 bit BMP. But from the command line, this works fine.
Code: Select all
convert infile.bmp +matte outfile.bmp
Expected:
- TrueColor and other settings such as Grey should work
- Even if TrueColor is not specified the default behavior for BMP should be TrueColor
- Only under exceptional circuimstances should a TrueColorMatte BMP be created.
Thank You for creating such a Wonderful Program!
-- Erik
~