Advertisement
Guest User

Asemblance Labs' Barcode Image Reader to Binary

a guest
Apr 28th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. from PIL import Image
  2. barcode = Image.open(r"C:\Users\James\Pictures\barcode.png")
  3.  
  4. outStrBin = ""
  5.  
  6. width, height = barcode.size
  7. for x in range(0,width):
  8.     pixel = barcode.getpixel((x,2))
  9.     if pixel[0]==255: #white
  10.         outStrBin+="1"
  11.     else: #black
  12.         outStrBin+="0"
  13.  
  14. print(outStrBin)
  15. barcode.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement