← Hashito System Home 日本語 Tools Blog

Everything runs inside your browser. Your image is never sent to a server.

Click to choose an image / drag & drop here / paste with Ctrl+V
Parameters

Several horizontal scan lines are taken from the image at different heights and skews, and each one is turned into a brightness profile. The falling and rising edges of that profile give the run lengths, from which the smallest module width is estimated; the grid is then fitted to the start guard and every module is re-read. Digits that could not be read are filled with tentative values, and only the combinations whose check digit works out are offered as candidates.

Manual editing: click the "restored modules" strip on the right to flip a module between black and white. Orange marks uncertain modules and a blue outline marks modules you edited by hand. The start guard, centre guard and stop pattern have fixed values in the specification, so they are used to score how well the grid fits.
How to use: load an image and the before/after previews appear on the right. Moving a slider retries the decode automatically. For photos where the thin bars have smeared together, try scale plus unsharp; for faint printing and receipts, try contrast plus binarization.

Automatically tries combinations of binarization threshold (including an automatically estimated one) x black/white inversion x rotation (0/90/180/270 degrees). Useful for photos where the barcode is standing vertically, or for labels printed white-on-black.

Tip: the attempts are split into small chunks so the page never freezes. On success the winning parameters and the symbology are shown.
Tip: camera shake and defocus are treated with an unsharp mask (a simple edge enhancement that adds back the difference from a blurred copy). The thinnest bars smear first, so match the radius to the width of the thinnest bar.
Preview and result

Region fix (for photos where only part of the image is broken)

Drag on the "before" preview below to select an area and the chosen operation is applied to that area only. You can invert just the part crushed by a shadow, or darken just the part that is blown out. Fixes stack up and can be removed one by one afterwards.

Before
After
Restored modules (click to flip black / white)
Black module (bar) White module (space) Uncertain (black ratio too close to call) Edited by hand
Brightness profile of the scan line (lower is darker; the line marks the decision threshold)
Tips for retaking the photo:
- Shoot under bright, even light and avoid glare and reflections
- Get close and head-on so the barcode fills the width of the frame, and hold still for a couple of seconds to focus
- Frame the shot so the quiet zones (the margins to the left and right of the bars) are included
- Vertically, a single intact scan line anywhere across the bars is often enough to recover the code
- For curved packaging, shoot from an angle where the label looks as flat as possible

About the Barcode Photo Restore tool

You photographed a product on the shelf or a shipping label, but the barcode will not scan - usually because of defocus, camera shake, uneven lighting, a shadow, a reflection, or simply too little resolution. This free online tool combines image processing (enhancement, locally adaptive binarization, region-limited fixes) with per-scan-line brightness profile analysis and the barcode-specific check digit to try to recover a barcode that could not be read.

Barcodes are harder to recover than QR codes

A QR code carries Reed-Solomon error correction and can mathematically recover up to about 30% of its area. An ordinary barcode has no error correction code at all. All it has is a single check digit at the end, and that exists to notice an error, not to fix one. In exchange, a barcode has a different strength: the same information is repeated as hundreds of scan lines down the height of the bars. If the top half is crushed by a shadow but one line in the bottom half survives, reading that line alone is enough.

Four ways to restore

Locally adaptive binarization and region fixes

A single threshold for the whole image crushes shadowed areas to solid black and blows out bright areas to solid white. This tool includes locally adaptive binarization (deciding black or white by comparing each pixel with the average brightness around it, computed quickly with an integral image) among its automatic attempts, so photos with uneven lighting are judged by "is this darker than its surroundings" instead. If that is still not enough, you can drag on the preview to invert, lighten, darken or fill with white just that area, stacking as many fixes as you need.

Narrowing candidates with the check digit

In EAN-13 (JAN-13) the 13th digit is a check digit, uniquely determined from the first 12 digits weighted 1, 3, 1, 3 and so on. Of all the combinations produced by guessing, only about one in ten passes the check digit. EAN-13 goes further: whether each of the six left-hand digits uses the odd-parity (L) or even-parity (G) encoding encodes the first digit, and only 10 of the 64 possible patterns are valid. CODE128 has a modulo-103 check character as well. This tool keeps only the combinations that satisfy all of these.

What it can and cannot do

It helps when an intact scan line survives above or below the damage, when the thin bars have smeared together, or when a shadow darkens one side. It struggles when bars are missing horizontally - when part of the number is simply gone. The more digits are lost, the more candidates survive, and the check digit alone cannot pick one. In that case several candidates are shown, but they contain guesses, so always cross-check against the physical item before using them. The ZXing (zxing-js) library is also used alongside the built-in reader.

Frequently Asked Questions

Is my image uploaded to a server?

No. Everything - loading, enhancement, binarization, scan line extraction and decoding - runs entirely inside your browser using Canvas and JavaScript. Neither the image nor the decoded result is ever sent to or stored on an external server, so you can safely use photos you would rather keep private, such as product packaging or shipping labels.

Which barcode symbologies are supported?

EAN-13 (JAN-13), UPC-A, EAN-8, CODE128 and CODE39. Only symbologies that were actually generated as images, damaged with a dark shadow and then recovered by this tool are listed here. EAN-13 and UPC-A share the same 95-module structure, so a UPC-A code is reported as UPC-A and its digits are shown as the 13-digit form including the leading zero.

How does the check digit help with recovery?

A barcode carries a check digit at the end, and comparing it with the value computed from the other digits tells you whether the reading is valid. Brute-forcing tentative values into the digits that could not be read produces many candidates, but keeping only the combinations whose check digit works out cuts them down to roughly one in ten. EAN-13 adds another rule: the pattern of odd-parity and even-parity encodings across the six left-hand digits encodes the first digit, and only 10 of the 64 possible patterns are valid. CODE128 also has a modulo-103 check character. This is a barcode-specific way to narrow down candidates that QR codes do not have.

Can every barcode be recovered?

No, recovery has limits. A barcode is one-dimensional, carries almost no redundancy, and has no error correction code like a QR code does. This tool looks for a readable scan line using multiple scan heights, skew correction and locally adaptive binarization, and fills in the remaining digits with tentative values checked against the check digit - but the more digits that cannot be read, the more candidates appear and the less certain the answer becomes. If any part of the bars survives vertically, recovery is likely; if the code is badly cut horizontally, it is difficult.

What does it mean that the candidates contain guesses?

The candidates are combinations produced by assigning tentative values to the digits that could not be read and keeping only those whose check digit works out. A valid check digit only guarantees that the value is not impossible; it does not guarantee that it matches the original barcode. Every candidate except one with zero guessed digits contains guesses. Always cross-check the number against the physical item or another source before using it for real work.