Save an image in a BMP uncompressed format.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mongoose54

Save an image in a BMP uncompressed format.

Post by mongoose54 »

I don't know if anyone know how I can save an image into BMP file in Imagemagick but being uncompressed, having 24bits per pixel (no alpha channel). ImageMagick saves an image into BMP by default in compressed and 32bits per pixels (alpha channel). Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Save an image in a BMP uncompressed format.

Post by fmw42 »

see http://www.imagemagick.org/Usage/formats/#bmp

I don't know about the compression, but

convert image +matte image.bmp

should save as 24-bit without alpha

You might also try

convert image +matte +compress image.bmp

to see if that will turn off the compression, if it is still there.
mongoose54

Re: Save an image in a BMP uncompressed format.

Post by mongoose54 »

Could you be more specific with the convert +matte command ? I mean the full syntax of these commands. I am using ImageMagick C++. Thanks for the fast response!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Save an image in a BMP uncompressed format.

Post by fmw42 »

Sorry, I know nothing about using IM in any API situation. I have only had experience with the command line IM.

All I can tell you is that +matte (or -alpha off) turns off the alpha channel. Similarly +compress turns off compression, but may be particular only to certain image types, such as jpg. I know little about +compress and which image types with which it can be used.

see http://www.imagemagick.org/script/comma ... p#compress
tehtarik
Posts: 1
Joined: 2013-01-13T19:54:42-07:00
Authentication code: 6789

Re: Save an image in a BMP uncompressed format.

Post by tehtarik »

Hi folks,

I know this is an old thread, but I am facing similar problems that lead me here. :)

I have an uncompressed .bmp file (containing a rectangular image) that I have crop using:
convert <file> -crop <dimension-x + y> <new-filename>

.BMP File is still uncompressed at this stage.

After the crop, I rotated using the following:
mogrify -alpha OFF -rotate 90 <new-filename>

The suddenly, this causes the new-filename to contain compressed BMP (as shown with a xxd check of the BMP file header).
Originally, I had not use the -alpha option (the +matte has been deprecated in v6.6.0-4 2010). Adding the -alpha OFF option did not solve that (having the same compressed final image).
I need my image to be uncompressed.

Any advice is appreciated. Thanks in advance.

Best regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Save an image in a BMP uncompressed format.

Post by fmw42 »

try saving to the older BMP formats by adding BMP3:image.bmp or BMP2:image.bmp see if that helps see http://www.imagemagick.org/Usage/formats/#bmp

Also if just processing one file, I would recommend using convert rather than mogrify.

Code: Select all

mogrify -alpha OFF -rotate 90 <new-filename>
convert inputimage -alpha off -rotate 90 outputimage

but the -alpha off could be left off, since it has nothing to do with compression.

Try adding -compress none and see if that helps

http://www.imagemagick.org/script/comma ... p#compress
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Save an image in a BMP uncompressed format.

Post by glennrp »

fmw42 wrote: but the -alpha off could be left off, since it has nothing to do with compression.
Actually alpha does have something to do with compression. If image->matte
is true (meaning alpha is present), the BMP encoder uses the BMP4 format.
See this comment in coders/bmp.c:
  • % WriteBMPImage() writes an image in Microsoft Windows bitmap encoded
    % image format, version 3 for Windows or (if the image has a matte channel)
    % version 4.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Save an image in a BMP uncompressed format.

Post by fmw42 »

I stand corrected. Thanks Glenn.
Post Reply