BGR to JPEG Converter
Convert raw BGR binary image data to JPEG format online. Specify dimensions, adjust quality, preview and download - all client-side.
About
Raw BGR files store pixel data as sequential B, G, R byte triplets with no header, no dimensions metadata, and no compression. Open one in the wrong tool and you get noise. Specify incorrect width and the image shears diagonally. This converter reads the raw byte stream, swaps the B and R channels to produce standard RGB ordering, renders onto a Canvas element, and encodes to JPEG at a user-defined quality factor Q โ [0.01, 1.0]. All processing is local. No upload occurs.
The tool validates that file size equals W ร H ร 3 bytes before proceeding. If your BGR data uses 4-byte row padding (common in BMP-derived pipelines), enable the padding option. Note: this tool assumes 8-bit unsigned integer samples. 16-bit or float BGR data requires separate handling.
Formulas
Each pixel in a raw BGR file occupies 3 consecutive bytes. The channel swap operation for pixel index i is:
The expected file size without row padding:
With 4-byte row alignment (BMP-style), each row is padded to a multiple of 4 bytes:
JPEG quality factor Q maps to the quantization table scaling inside the encoder. Q = 1.0 yields minimal quantization (largest file, best fidelity). Q = 0.01 yields aggressive quantization (smallest file, most artifacts).
Where: W = image width in pixels, H = image height in pixels, S = file size in bytes, Q = JPEG quality factor (0.01 - 1.0), stride = padded row length in bytes.
Reference Data
| Raw Format | Channel Order | Bytes/Pixel | Header | Common Source |
|---|---|---|---|---|
| BGR24 | B G R | 3 | None | OpenCV cv::Mat dump |
| BGRA32 | B G R A | 4 | None | Windows GDI bitmaps |
| RGB24 | R G B | 3 | None | Most image libraries |
| RGBA32 | R G B A | 4 | None | Canvas API getImageData |
| BMP | B G R (padded rows) | 3+pad | 54 bytes | Windows Paint |
| PPM (P6) | R G B | 3 | ASCII header | Netpbm suite |
| JPEG | Y Cb Cr (DCT) | Variable | SOI marker | Cameras, web |
| PNG | R G B A | Variable | PNG signature | Web, screenshots |
| TIFF | Configurable | Variable | IFD structure | Print, medical |
| YUV420 | Y U V | 1.5 | None | Video codecs |
| NV12 | Y + interleaved UV | 1.5 | None | Hardware decoders |
| Bayer RGGB | Mosaic pattern | 1 | None | Camera sensors (RAW) |
Frequently Asked Questions
toBlob('image/png').