PNG to BGR Converter

Decodes an uploaded PNG onto a canvas, drops its alpha channel, and downloads the remaining color values as a raw blue-green-red byte dump with no header — the pixel layout legacy Windows APIs, OpenCV, and some camera pipelines expect. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

This tool exports a PNG's pixels as a raw BGR byte dump entirely in your browser, matching the blue-first channel order many native imaging libraries expect.

Nothing leaves your device; decoding and byte reordering both happen on an off-screen canvas.

What Is PNG to BGR Converter?

A client-side PNG-to-raw-BGR converter that reads an uploaded PNG's decoded pixels and repacks each one as 3 bytes in blue, green, red order, dropping the alpha channel entirely.

The output has no header — it's a flat array matching what a `cv::Mat` in OpenCV, or a classic Windows DIB row, stores per pixel.

How PNG to BGR Converter Works

The upload panel decodes the PNG into a plain RGBA pixel buffer via canvas, then this tool's pure function walks every pixel and writes its blue, green, and red channel bytes (in that order) into a new buffer, skipping alpha.

The resulting byte array is offered as a direct download with no compression, chunk structure, or metadata around it.

When To Use PNG to BGR Converter

Use it when feeding pixel data into OpenCV, a legacy Windows imaging API, or any pipeline documented as expecting BGR channel order.

It's also useful when debugging a 'colors look swapped' issue, since you can generate a known-BGR reference file to compare against.

Features

Advantages

  • Runs entirely client-side; your image never leaves the browser.
  • Matches the exact byte order many native computer-vision and legacy imaging pipelines require.
  • No compression or metadata overhead in the output file.

Limitations

  • Transparency is permanently discarded; use the BGRA variant if you need to keep it.
  • The output file stores no dimensions, so width and height must be tracked separately.

Examples

Prepare a frame for an OpenCV pipeline

Input

A 32x32 opaque PNG

Output

A 3,072-byte (32 x 32 x 3) raw BGR buffer

OpenCV's cv::imdecode/cv::Mat conventions expect exactly this blue-first byte order by default.

Debug a color-swap issue

Input

A red test-pattern PNG

Output

A BGR dump whose first byte per pixel is 0 (blue) rather than 255 (red)

Comparing this against an RGB export makes a channel-order bug immediately visible.

Best Practices & Notes

Best Practices

  • Record the source image's width and height before downloading, since the raw file doesn't store them.
  • Double check whether your target library truly expects BGR — many modern web and mobile APIs use RGB(A) instead.

Developer Notes

The pure conversion loop lives in a lib function that operates on a plain PixelBuffer and returns a Uint8Array with no DOM dependency, reading the RGBA source 4 bytes at a time and writing blue/green/red (3 bytes) at a time to the output.

PNG to BGR Converter Use Cases

  • Feeding pixel data into an OpenCV or legacy Windows imaging pipeline
  • Producing test fixtures for BGR-vs-RGB channel-order bugs
  • Preparing raw pixel data for a camera or embedded-vision pipeline

Common Mistakes

  • Using this when the target actually expects RGB order, producing visibly swapped red/blue colors.
  • Forgetting to record width/height, making the raw bytes impossible to reinterpret later.

Tips

  • Pair this with the matching BGR to PNG converter to verify a round trip reproduces the original opaque pixels exactly.
  • If your target format needs alpha preserved, use the PNG to BGRA converter instead.

References

Frequently Asked Questions