Update app.py

This commit is contained in:
pliny 2024-10-12 18:31:57 -04:00 committed by GitHub
parent a8cff45707
commit 62be3fbb8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

4
app.py
View File

@ -19,9 +19,9 @@ def encode_text_into_image(image_path, text, output_path):
img = Image.open(image_path)
img = img.convert("RGBA") # Ensure image has alpha channel
# Convert text to binary
# Convert text to binary and repeat the text to improve robustness
binary_text = ''.join(format(ord(char), '08b') for char in text) + '00000000' # Add terminator
repeated_binary_text = binary_text * 10 # Increase redundancy by repeating the message 10 times
repeated_binary_text = binary_text * 10 # Embed the message 10 times for redundancy
width, height = img.size
pixel_count = width * height