Skip to content

Instantly share code, notes, and snippets.

@MahraibFatima
Created February 26, 2024 14:36
Show Gist options
  • Save MahraibFatima/ca95b5f486f6a3097ce8621435e322b8 to your computer and use it in GitHub Desktop.
Save MahraibFatima/ca95b5f486f6a3097ce8621435e322b8 to your computer and use it in GitHub Desktop.
This code will decode the QR code or barcode data from the PNG image using "pyzbar" and then print the decoded data as ASCII. In this we have to replace "your_image.png" with the path to our actual PNG file.
from PIL import Image
from pyzbar.pyzbar import decode
image = Image.open("your_image.png")
decoded_objects = decode(image)
for obj in decoded_objects:
print(obj.data.decode('ascii'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment