# man > ppmtobmp(1)

> **TLDR:** Convert a PPM image to a BMP file.
>
- Convert a PPM image to a BMP file:
  `ppmtobmp {{path/to/file.ppm}} > {{path/to/file.bmp}}`
- Explicitly specify whether or not a Windows BMP file or an OS/2 BMP file should be created:
  `ppmtobmp -{{windows|os2}} {{path/to/file.ppm}} > {{path/to/file.bmp}}`
- Use a specific number of bits for each pixel:
  `ppmtobmp {{-b|-bbp}} {{1|4|8|24}} {{path/to/file.ppm}} > {{path/to/file.bmp}}`

*Source: tldr-pages*

---

_Ppmtobmp_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)                General Commands Manual               _Ppmtobmp_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)

## NAME
       ppmtobmp - convert a PPM image into a BMP file


## SYNOPSIS
### ppmtobmp

       [**-windows**]

       [**-os2**]

       [**-bpp=_**bits_per_pixel_]

       [**-mapfile=_**filename_]

       [_ppmfile_]

       Minimum  unique  abbreviation of option is acceptable.  You may use double hyphens instead of
       single hyphen to denote options.  You may use white space in place of the equals sign to sep‐
       arate an option name from its value.



## DESCRIPTION
       This program is part of [**Netpbm**(1)](https://www.chedong.com/phpMan.php/man/Netpbm/1/markdown).

       **ppmtobmp **reads a PPM image as input and produces a Microsoft Windows or OS/2 BMP file as out‐
       put.


## OPTIONS
       In addition to the options common to all programs based on libnetpbm  (most  notably  **-quiet**,
       see ]8;;index.html#commonoptions\ Common Options]8;;\ ), **ppmtobmp **recognizes the following command line options:



### -windows
              Tells the program to produce a Microsoft Windows BMP file.  (This is the default.)


### -os2   
              fault).


### -bpp   
              and  24  are possible.  By default, **ppmtobmp **chooses the smallest number with which it
              can represent all the colors in the input image.  If you specify a number too small to
              represent all the colors in the input image, **ppmtobmp **tells you and  terminates.   You
              can use **pnmquant **or **ppmdither **to reduce the number of colors in the image.

              Before  Netpbm 10.85 (December 2018), **ppmtobmp **ignores this option if the input is PBM
              and produces a BMP with 1 bit per pixel.  With these versions, if you want  more  than
              that, use **pbmtopgm **to convert the PBM to PGM first.


### -mapfile=_
              This identifies a file to use as the BMP palette (aka "colormap").  In one BMP subfor‐
              mat,  the  BMP stream contains a palette of up to 256 colors, and represents the image
              raster as indices into that palette.  Normally, **ppmtobmp **takes  care  of  computing  a
              suitable  palette, but if you are going to dissect the BMP output in some way, you may
              want certain values for the palette indices.  E.g. you might want red to be 13,  where
              **ppmtobmp  **would  (arbitrarily) choose 39.  In that case, you can construct the palette
              yourself and use this option to tell **ppmtobmp **to use your palette.

              This option does _not_ control what colors are in the output.  The colors in the  output
              are  exactly  those in the input, and the palette you supply must contain at least all
              the colors that are in the input.  You can use **pnmremap **to adjust your input image  so
              that it contains only colors from your palette.

              The palette file is a Netpbm format file with one pixel per palette entry.  Each pixel
              must have a distinct color (no repeats).  The order of the BMP palette **ppmtobmp **gener‐
              ates is the order of the pixels in the palette file, going from top to bottom, left to
              right.

              A  BMP  palette may have at most 256 colors, so the palette file must have at most 256
              pixels.

              You may find **pnmcolormap **useful in generating the palette file.  **pamseq **too.

              In the case of grayscale image, if you are processing the BMP image, it
                may be convenient for you to have the actual gray values in the raster
                part of the image rather than arbitrary indices into a palette.  There is
                no BMP format specifically for that, but you can achieve it by using a
                palette in which each index is equal to the indexed gray value, and then
                ignoring the palette when you process the BMP image.

              Here is an example of doing that:


                  $ pamseq 1 255 > mapfile.pgm

                  $ ppmtobmp -mapfile=mapfile.pgm input.pgm > output.bmp



              This option was new in Netpbm 10.45 (December 2008).





## NOTES
       To get a faithful reproduction of the input image, the maxval of the input image must be 255.
       If it is something else, the colors in the BMP file may be slightly different from the colors
       in the input.

       Windows icons are not BMP files.  Use **ppmtowinicon **to create those.


## SEE ALSO
       [**bmptoppm**(1)](https://www.chedong.com/phpMan.php/man/bmptoppm/1/markdown), [**ppmtowinicon**(1)](https://www.chedong.com/phpMan.php/man/ppmtowinicon/1/markdown), [**pnmquant**(1)](https://www.chedong.com/phpMan.php/man/pnmquant/1/markdown), [**ppmdither**(1)](https://www.chedong.com/phpMan.php/man/ppmdither/1/markdown), [**pnmremap**(1)](https://www.chedong.com/phpMan.php/man/pnmremap/1/markdown), [**ppm**(1)](https://www.chedong.com/phpMan.php/man/ppm/1/markdown)


## AUTHOR
       Copyright (C) 1992 by David W. Sanderson.

## DOCUMENT SOURCE
       This manual page was generated by the Netpbm tool 'makeman' from  HTML  source.   The  master
       documentation is at

              **<http://netpbm.sourceforge.net/doc/ppmtobmp.html>**

netpbm documentation                      20 December 2018                   _Ppmtobmp_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)
