How to Read a QR Code From an Image File on Your Computer — featured illustration
Tutorials

How to Read a QR Code From an Image File on Your Computer

7 min read
Create a QR code

A colleague forwards a PNG. A supplier's invoice arrives as a PDF with a payment code on page two. A screenshot lands in a group chat with a code in the corner. In all three cases the code is already a file on a computer, and every instruction on the internet tells you to point a phone at it.

What this is not

Three adjacent problems get answered with the same articles, and only one of them is this one.

Scanning something printed by holding it up to a laptop webcam is a camera problem, covered in scanning a QR code on a computer. Reading a code displayed on another screen, a monitor or a tablet in front of you, is an optics problem with its own failure list in why a code will not scan from another screen. This post is the third case: the code exists as pixels in a file you already have, no camera is involved, and what you want is the string inside it.

That case is easier than the other two, because a file does not move, does not reflect anything, and holds exactly as much detail as it holds. Everything below is either instant or impossible, and the last section tells you which.

Drag the file into a browser and read it there

The shortest path with nothing installed is a decoder running in a browser tab. Open a page that reads a code from a picture, drag the PNG, JPG or screenshot onto it, and read the result as text.

Two things are worth doing before you drag. Crop tightly around the code while leaving its light margin intact, because extra background gives the detector more candidate regions and more chances to lock onto the wrong thing. And if the file is sensitive, an invoice with account numbers on it or a badge with a name, check whether the tool decodes inside your browser or uploads the image to a server. Tools that work locally generally say so.

What you want back is text, not a redirect. A decoder that immediately navigates to whatever it found has made the decision on your behalf, which matters when the file came from someone you do not know; reading a code's link before you tap it covers what to look for in the string once you are holding it.

The right-click route, including for local files

If the code is an image on a web page, Chrome reads it from the context menu: right-click the image, choose the Google Lens search action, and the decoded address appears in the side panel that opens. Edge has an equivalent through its own visual search. Firefox and Safari do not.

The trick most people miss is that this works on local files too. Drag the PNG onto an empty browser tab, or open it with the file-open shortcut, and the browser renders it as an ordinary image element. Right-click it there and the same action is available. That converts a feature people think of as a web-page tool into a general file decoder with no upload page involved at all.

It fails in predictable ways. A code drawn inside a canvas element, rendered by a PDF viewer, or baked into a larger banner image will not offer the option, because there is no discrete image for the browser to act on.

On a Mac, the file previewer already does it

macOS recognizes content inside images system-wide, and a QR code counts as content. Select the file in Finder and press the space bar for Quick Look, or open it in Preview or Photos, and on recent versions a control appears offering the destination. Exactly what that control looks like, and what Apple calls the feature, has shifted across releases, so check your own machine before installing anything; there is a good chance the file you are staring at is one keypress from decoded.

Recent macOS also ships a Shortcuts action that detects barcodes in an image, which is the route to use when you have forty files rather than one. A two-step shortcut that takes image input and returns the decoded text can be run straight from the Finder's quick actions menu, and it never touches a network.

Scanning a code on a Mac has the full walkthrough, including the iPhone handoff that is still the better option for anything physical.

On Windows, crop first and decode second

Windows has no system decoder you can count on across versions, so the reliable sequence is to get a clean crop and hand it to a browser.

Win + Shift + S opens the snipping overlay. Drag a rectangle around the code, keeping the light border, and the capture lands on the clipboard, where most browser decoders accept a direct paste. That single shortcut solves most of this problem on most machines.

Recent Snipping Tool builds go further, adding text actions that lift a URL out of a capture and, in newer versions, detecting a code in the snip itself. Whether yours does depends on the app version, which updates through the Store separately from Windows, so look at the toolbar after you capture rather than trusting any tutorial's screenshot. Scanning a code on Windows covers the camera and browser paths in order.

One habit is worth building here: zoom the source before you snip. A code displayed at thirty percent in a PDF viewer gives you a sixty-pixel capture, while the same code at four hundred percent gives you a clean one. The snipping tool captures what is on screen, so make the code big on screen first.

Codes inside a PDF

Try the boring thing before anything else. A great many codes in PDFs sit next to, or directly on top of, a real hyperlink annotation. Hover over the code, or right-click it and look for a copy-link option. If the link is there, you never needed to decode anything.

If it is not, the outcome depends on how the code was placed in the document. A code drawn as vectors scales without limit: zoom the page to four hundred percent or more, snip the code, and it decodes cleanly every time. A code embedded as a low-resolution raster does not improve when you zoom, because you are magnifying the same handful of pixels, and no upscaling invents modules that were never stored. For that one, ask the sender for the original image or the plain address.

The middle route is exporting the page. Most PDF viewers can save a page as an image at a resolution you choose; anything at 300 dpi or above usually produces a file a decoder handles without complaint.

When the file does not contain enough code

Four failures account for nearly everything else, and three of them cannot be fixed on your end.

The code is too small in the source. A decoder needs a few pixels per module to sample reliably, and a code thirty-three modules across wants well over a hundred pixels of width before it is comfortable. A forty-pixel code holds roughly one pixel per module, which is not a thin margin, it is no margin. Upscaling produces a larger blur and nothing else.

The screenshot went through a chat app. Messaging platforms recompress images, and compression puts ringing artifacts exactly where the decoder is looking, on the hard edges between light and dark modules. Ask for the original file instead of the forwarded screenshot; it usually still exists somewhere.

Something is sitting on the code. A play button, a watermark, a swipe-up chip, a notification banner that got captured in the screenshot. Error correction repairs a bounded proportion of damaged modules, so a small overlay in the data area is often survivable. An overlay across one of the three corner squares is not, because a reader locates the code by those squares and never gets as far as decoding anything.

The margin was cropped off. This is the common one, and it is the only one you can repair: the light border around a code is part of the specification, and a tight crop that shaves it is the usual reason a screenshot fails when the original read perfectly. Re-crop wider from the source file.

If none of that lands, the fastest remaining move is not technical. Reply to whoever sent the file and ask for the address as text, which is what should have been in the message in the first place.

Share this article