Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import hashlib
|
|
| 3 |
import qrcode
|
| 4 |
from PIL import Image, ImageDraw
|
| 5 |
import os
|
|
|
|
| 6 |
|
| 7 |
# Function to hash image data
|
| 8 |
def hash_image(image):
|
|
@@ -23,11 +24,14 @@ def generate_qr_code(data):
|
|
| 23 |
qr_img = qr.make_image(fill='black', back_color='white')
|
| 24 |
return qr_img
|
| 25 |
|
| 26 |
-
|
| 27 |
def embed_qr_code(image, qr_img):
|
|
|
|
|
|
|
| 28 |
image.paste(qr_img, (10, 10)) # Adjust position as needed
|
| 29 |
return image
|
| 30 |
|
|
|
|
| 31 |
# Function to save hash to file
|
| 32 |
def save_hash(hash_code, description=""):
|
| 33 |
with open("hash.txt", "a") as file:
|
|
|
|
| 3 |
import qrcode
|
| 4 |
from PIL import Image, ImageDraw
|
| 5 |
import os
|
| 6 |
+
from PIL import Image
|
| 7 |
|
| 8 |
# Function to hash image data
|
| 9 |
def hash_image(image):
|
|
|
|
| 24 |
qr_img = qr.make_image(fill='black', back_color='white')
|
| 25 |
return qr_img
|
| 26 |
|
| 27 |
+
|
| 28 |
def embed_qr_code(image, qr_img):
|
| 29 |
+
if isinstance(image, np.ndarray):
|
| 30 |
+
image = Image.fromarray(image.astype('uint8')) # Convert NumPy array to PIL Image
|
| 31 |
image.paste(qr_img, (10, 10)) # Adjust position as needed
|
| 32 |
return image
|
| 33 |
|
| 34 |
+
|
| 35 |
# Function to save hash to file
|
| 36 |
def save_hash(hash_code, description=""):
|
| 37 |
with open("hash.txt", "a") as file:
|