User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Drop BGR file here or click to browse Accepts raw .bgr, .raw, .bin, .dat or any file
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

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.

bgr to jpeg raw image converter bgr rgb swap image format converter raw to jpeg

Formulas

Each pixel in a raw BGR file occupies 3 consecutive bytes. The channel swap operation for pixel index i is:

Rout = Bin , Gout = Gin , Bout = Rin

The expected file size without row padding:

S = W ร— H ร— 3 bytes

With 4-byte row alignment (BMP-style), each row is padded to a multiple of 4 bytes:

stride = โŒˆ W ร— 3 รท 4 โŒ‰ ร— 4
Spadded = stride ร— H 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 FormatChannel OrderBytes/PixelHeaderCommon Source
BGR24B G R3NoneOpenCV cv::Mat dump
BGRA32B G R A4NoneWindows GDI bitmaps
RGB24R G B3NoneMost image libraries
RGBA32R G B A4NoneCanvas API getImageData
BMPB G R (padded rows)3+pad54 bytesWindows Paint
PPM (P6)R G B3ASCII headerNetpbm suite
JPEGY Cb Cr (DCT)VariableSOI markerCameras, web
PNGR G B AVariablePNG signatureWeb, screenshots
TIFFConfigurableVariableIFD structurePrint, medical
YUV420Y U V1.5NoneVideo codecs
NV12Y + interleaved UV1.5NoneHardware decoders
Bayer RGGBMosaic pattern1NoneCamera sensors (RAW)

Frequently Asked Questions

Raw BGR files have no header. You must know the dimensions from the source application. If unknown, divide file size by 3 to get total pixel count, then find factor pairs. For example, a 921,600-byte file contains 307,200 pixels, which factors as 640 ร— 480. If the image appears sheared or skewed, the width is wrong.
The converter will reject the file and display the expected size versus actual size. Common causes: the file includes a header (e.g., BMP's 54-byte header was not stripped), row padding is present (enable the padding toggle), or the data is BGRA (4 bytes per pixel) rather than BGR (3 bytes per pixel).
No. JPEG is inherently lossy. A quality factor of 1.0 (100%) minimizes quantization but still applies DCT-based compression with some information loss. For mathematically lossless output, use PNG. The Canvas API supports PNG via toBlob('image/png').
This version processes BGR24 (3 bytes per pixel). For BGRA32 data, each pixel has an extra alpha byte. The expected file size would be W ร— H ร— 4. You can enable the BGRA toggle in the settings to handle 4-channel data.
BMP-derived BGR data is often stored bottom-row-first (bottom-up scan order). Enable the "Flip Vertically" option to invert the row order during conversion. This is standard for Windows DIB sections and many OpenCV raw dumps on Windows.
The tool caps at 8192 ร— 8192 pixels. Canvas memory consumption is W ร— H ร— 4 bytes for the RGBA buffer. An 8192 ร— 8192 image uses approximately 256 MB of RAM. Exceeding browser memory limits will trigger an error toast.