BMP resolution units

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
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

BMP resolution units

Post by el_supremo »

There's a bug in the bmp.c coder. It correctly converts the x and y resolution values from pixels per metre to pixels per centimetre but it leaves the units as undefined which means that the resolution and units won't be correctly propagated when converting to other image formats (such as PNG,JPG etc).
In the ReadBMPImage function there is this code at about line 893:
/*
Initialize image structure.
*/
image->x_resolution=(double) bmp_info.x_pixels/100.0;
image->y_resolution=(double) bmp_info.y_pixels/100.0;

Add the statement:
image->units=PixelsPerCentimeterResolution;

When this statement is added, converting a BMP to another image format will result in the correct resolution and units in the output file (if it supports resolution units at all).

<spelling nitpick>
The "metre" is the unit of length. A "meter" is used to measure quantities such as volts or amps. It took me a while to figure out why my fix to bmp.c kicked out a compiler error for PixelsPerCentimetreResolution.
It would be nice if ImageMagick.h could have the statement:
#define PixelsPerCentimeterResolution PixelsPerCentimetreResolution
added immediately before the enum that defines it.
</spelling nitpick>

Pete
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Thanks for the problem report and patch. We will get it into the latest the ImageMagick development version.
Post Reply