How to Convert BMP to JPG or PNG
A BMP is a plain grid of pixels with almost no compression, so converting it to JPG or PNG typically shrinks it a lot. You can also predict its size exactly from its dimensions, which is a useful check on what kind of BMP you have.
By the Universal Image Converter Team
Steps
- Add the BMP files to the converter.
- Choose JPEG for photographs and scans of photographs, or PNG for screenshots, drawings and anything with text.
- For JPEG, start with the quality slider where it is and lower it only if size matters more.
- If a 32-bit BMP carries transparency and you chose JPEG, pick the background color for those areas.
- Compare the sizes shown, then download.
Where BMP files usually come from
BMP is Microsoft's old Windows bitmap format, and you tend to meet it in a few places: drawings and screenshots saved from older Windows programs such as Paint, scans from older scanner software, images exported from legacy industrial or lab equipment, and graphics bundled with old applications. Few cameras and phones write BMP at all. Because these sources produce flat uncompressed pixels, the right output follows the content: a scanned photo becomes a JPG, a Paint drawing becomes a PNG. Browsers can display most BMPs, but may fail on rarely used variants, such as ones with unusual headers or embedded JPEG or PNG data; if a file will not open, that is a likely reason.
Why the size is exactly 54 plus the pixel rows
An uncompressed 24-bit BMP starts with a 14-byte file header and a 40-byte information header, 54 bytes in all. After that come the pixel rows. Each pixel takes 3 bytes (blue, green, red), and each row is padded with zero bytes up to a multiple of 4 bytes. The total is:
size = 54 + rows x paddedRowBytes
paddedRowBytes = ceil(width x 3 / 4) x 4Worked example 1: a 1920 x 1080 picture. A row is 1920 x 3 = 5,760 bytes, already a multiple of 4, so no padding. The size is 54 + 1080 x 5,760 = 54 + 6,220,800 = 6,220,854 bytes, about 5.9 MiB. I created such a file with Pillow and it was 6,220,854 bytes exactly.
Worked example 2: a 1001 x 3 picture. A row is 3,003 bytes, which rounds up to 3,004 for padding. The size is 54 + 3 x 3,004 = 9,066 bytes. Pillow gave 9,066 as well.
If a BMP's size does not match the formula, it is not a plain 24-bit file. A size close to 54 + rows x width x 4 points to a 32-bit file; a file much smaller than expected points to RLE compression or a palette of 256 colors or fewer.
24-bit, 32-bit and bottom-up rows
24-bit BMPs store red, green and blue only, no transparency. 32-bit BMPs add a fourth byte per pixel. Whether that byte is a real alpha channel or unused padding depends on the program that wrote the file, and programs disagree, so a 32-bit BMP may show up with a black or opaque background in one viewer and with transparency in another. The converter's own BMP output is 24-bit without alpha, so choosing BMP as the output target always flattens transparency onto the background color.
Rows in the common BMP layout are stored bottom-up: the first row in the file is the bottom row of the picture. A positive height value in the header signals this; a negative height means top-down order. You do not need to deal with this when converting, because the browser reads it correctly. It matters only if a BMP appears upside down in a program that ignores the flag; converting the file removes the problem.
Reading the header with a hex dump
You can check the formula on your own file. Print the first 54 bytes in a terminal:
xxd -l 54 picture.bmpBytes 0 and 1 are the letters BM (42 4D). The width is a 4-byte little-endian number at offset 18, the height at offset 22, and the bits per pixel is a 2-byte number at offset 28. For a 1920 x 1080 file at 24 bits you would see 80 07 00 00 at offset 18 (0x0780 = 1920), 38 04 00 00 at offset 22 (0x0438 = 1080), and 18 00 at offset 28 (0x0018 = 24). Bytes at offset 30 hold the compression type, where zero means none. If bits per pixel reads 32 you have the 32-bit kind; if it reads 8 or fewer, the file uses a color table and its size will not follow the 24-bit formula.
How much smaller the JPG or PNG gets
I encoded two synthetic 1920 x 1080 pictures, both 6,220,854 bytes as BMP: a page of text on white with a blue block, and a noisy gradient. The text page became 295,077 bytes as JPG at quality 90 and 213,652 as PNG. The noisy gradient became 876,842 bytes as JPG at 90, and 2,423,966 bytes as PNG. So the JPG was about 21 times smaller than the BMP for the text page and about 7 times smaller for the noisy picture; PNG was 29 times smaller on the text page, but only 2.6 times on the noisy picture. Real scans lie somewhere between, and a browser's encoder will give slightly different numbers.
Put differently: PNG gives you the same pixels with no loss and still shrinks flat pictures dramatically. JPG is smaller for photographs and scans, at the price of loss, whose size depends on the quality value; lossy vs lossless formats explains the trade.
Fitting a scanned BMP under an upload limit
Scans are the case where BMP size surprises people most. A letter-size page scanned at 300 dpi in color is 8.5 x 11 inches, which is 2,550 x 3,300 pixels, 8.4 megapixels. As an uncompressed 24-bit BMP, that is about 54 + 3,300 x 7,652 = 25,251,654 bytes, roughly 25 MB, since a 2,550 pixel row needs 7,650 bytes, padded up to 7,652. A web form with a 5 MB limit cannot accept that, and even a 10 MB limit rejects it. A JPG of the same scan at moderate quality is a small fraction of the BMP size, with the exact result depending on the paper and content. If it is still too large, choose 1920 pixels as the maximum size; the page becomes 1920 x 2485, 4.8 megapixels, 57 percent of the original pixel count, and text remains readable for most forms.
Choosing between JPG and PNG for a BMP
- Scan of a photograph or document page in color: JPG at 85 to 90.
- Black and white or text-heavy scan: PNG. JPG would add speckle around letters.
- Screenshot or drawing from Paint: PNG; it is smaller than the JPG and exact.
- Needs transparency: only a 32-bit BMP with a real alpha channel could carry it, and support varies. Convert to PNG and check whether the transparent area survived.
- Needed for upload to a form: check the size limit first. A 6 MB BMP exceeds many limits; any conversion will fix that. See why a website rejects your image for other causes.
Add your BMP files and compare the before and after sizes for JPG and PNG.
Open the image converter