BMP libraries
Open-source libraries that decode and encode BMP files. Almost every image library reads the common 24-bit BMP; they differ in how they handle the rarer variants (RLE, 16-bit bit fields, OS/2 headers, V4/V5 headers with alpha) and in which bit depths they can write.
| Language | Library | Read | Write | Notes |
|---|---|---|---|---|
| C/C++ | stb_image | yes | yes | single header; no RLE; writes 24-bit or 32-bit with alpha |
| C/C++ | SDL | yes | yes | SDL_LoadBMP, SDL_SaveBMP; reads RLE |
| C# | ImageSharp | yes | yes | all header versions, RLE4/8/24; writes 1-32 bit |
| C# | Magick.NET | yes | yes | ImageMagick; BMP2, BMP3 and V5 output |
| Java | ImageIO | yes | yes | built into the JDK; writes RLE, no alpha |
| Java | TwelveMonkeys | yes | yes | ImageIO plugin, reads every BMP variant, plus ICO and CUR |
| Go | x/image/bmp | yes | yes | official extension package; no RLE |
| Go | imaging | yes | yes | resize, crop, convert; uses x/image/bmp |
| Python | Pillow | yes | yes | reads RLE and OS/2; writes 1, 8, 24 and 32-bit |
| Python | OpenCV | yes | yes | images as NumPy arrays |
| Ruby | MiniMagick | yes | yes | wraps the ImageMagick command line |
| Rust | image | yes | yes | pure Rust; reads RLE and bit fields |
| PHP | GD | yes | yes | bundled with PHP 7.2+; writes RLE |
| PHP | Imagick | yes | yes | ImageMagick extension |
| PHP | Intervention Image | yes | yes | fluent API over GD or Imagick |
By language#
- BMP libraries for C/C++ Open-source C/C++ libraries to read and write BMP images: stb_image and SDL. Comparison, supported BMP variants and code examples.
- BMP libraries for C# Open-source C# libraries to read and write BMP images: ImageSharp and Magick.NET. Comparison, supported BMP variants and code examples.
- BMP libraries for Java Open-source Java libraries to read and write BMP images: ImageIO and the TwelveMonkeys BMP plugin. Comparison, supported BMP variants and code examples.
- BMP libraries for Go Open-source Go libraries to read and write BMP images: golang.org/x/image/bmp and imaging. Comparison, supported BMP variants and code examples.
- BMP libraries for Python Open-source Python libraries to read and write BMP images: Pillow and OpenCV. Comparison, supported BMP variants and code examples.
- BMP libraries for Ruby Open-source Ruby libraries to read and write BMP images: MiniMagick, which runs ImageMagick. Supported BMP variants and code examples.
- BMP libraries for Rust Open-source Rust libraries to read and write BMP images: the image crate. Supported BMP variants and code examples.
- BMP libraries for PHP Open-source PHP libraries to read and write BMP images: GD, Imagick and Intervention Image. Comparison, supported BMP variants and code examples.