Is there a way to turn a binary code into a QR code programmatically?

I have the following:

1 1 1 1 1 1 1   1   1   1 1   1     1 1 1 1 1 1 1 
1           1     1 1 1 1 1     1   1           1
1   1 1 1   1   1 1 1         1     1   1 1 1   1 
1   1 1 1   1   1 1 1   1   1 1     1   1 1 1   1 
1   1 1 1   1   1     1 1   1 1 1   1   1 1 1   1 
1           1       1 1   1     1   1           1 
1 1 1 1 1 1 1   1   1   1   1   1   1 1 1 1 1 1 1 
                    1   1     1 1                 
1 1 1 1     1   1   1 1 1 1   1 1 1     1 1 1   1 
    1         1     1   1 1 1   1     1   1       
1 1   1 1 1 1     1 1 1 1 1     1         1       
    1 1 1     1   1 1           1 1       1 1 1   
    1 1 1 1 1 1   1 1   1   1     1 1 1 1   1 1   
      1   1   1 1 1   1 1   1 1 1   1 1 1   1 1 1 
  1   1     1 1 1     1   1           1       1   
1   1 1 1 1     1   1 1     1         1       1 1 
    1   1 1 1 1 1   1   1   1   1 1 1 1 1   1 1   
                1   1       1 1 1       1 1 1   1 
1 1 1 1 1 1 1     1 1     1 1   1   1   1     1 1 
1           1     1   1   1 1 1 1       1         
1   1 1 1   1     1       1 1   1 1 1 1 1         
1   1 1 1   1   1 1 1             1 1   1 1   1 1 
1   1 1 1   1   1 1         1   1   1 1 1     1   
1           1   1     1 1 1 1     1       1 1     
1 1 1 1 1 1 1   1   1 1             1     1 1 1 1 

      

and it will not scan the QR code reader. Is there a way to change this to an actual QR code so that it is scannable?

+3


source to share


2 answers


Since you already know which squares are black and which are not, you can simply use pillow to create the image. You will need to use ImageDraw and Image . What you need to do is something like:



from PIL import Image, ImageDraw
im = Image.new('1', (width, height), color=1) # Background white
draw = ImageDraw.Draw(im)
draw.point((x, y), 0) # Draw black

      

+3


source


In fact, I actually turned the background of my text editor white, replacing all characters 1

with two characters

██

, taking a screenshot, and then shrinking the image so it wasn't "t so common."



Just thought I'd add this for completeness.

0


source







All Articles