A barcode is a number written in a font that machines can read at arm's length, at an angle, in motion. The whole trick is encoding digits as widths — of dark bars and the light spaces between them.
In EAN-13, each digit becomes a fixed pattern of two bars and two spaces whose widths are multiples of a base unit (the X-dimension, or module). The spaces carry exactly as much information as the bars — which is why ink bleeding into the spaces (ink gain) breaks scanning, and why generators offer Bar Width Reduction to pre-compensate.
Symbols begin and end with distinctive guard patterns so the scanner knows where the code starts and which direction it is being read — EAN's digit sets are designed so an upside-down scan is detected and simply reversed. The quiet zones (blank margins) are how the scanner finds the symbol's edges at all; crowd them and the code becomes invisible.
A laser scanner sweeps a red beam and measures reflected brightness over time — dark bars absorb, light spaces reflect — turning geometry into a waveform, then into widths, then digits. A camera imager (and every phone) photographs the code and does the same analysis in software, in 2D, which is why imagers also read QR and Data Matrix while lasers cannot. Red lasers are also why red bars fail: red ink reflects red light, reading as blank.
Decoded digits are checked against the final check digit (the Mod-10 math in our check-digit guide). Mismatch → the scanner stays silent rather than passing a wrong number to the till. Beep = geometry, optics and arithmetic all agreeing in about ten milliseconds. See it end to end by making one in the generator.