正在尝试使用PIL在图像的二进制文件中对一些加密数据进行编码。 这是我的代码:
from PIL import Image
image_location=input("Enter the image to encode : ")
image = Image.open(image_location)
image.save("Encoded_"+image_location)
modify_img=Image.open("Encoded_"+image_location)
img_size=modify_img.height * modify_img.width
print("[*]Maximum bytes to encode : ",img_size)
payload="01110100 01100101 01110011 01110100 "
for row in modify_img:
for pixel in row:
#for red
if data_index < data_len:
pixel[0] = int(r[:-1] + binary_secret_data[data_index], 2)
data_index += 1
#for green
if data_index < data_len:
pixel[0] = int(g[:-1] + binary_secret_data[data_index], 2)
binary_secret_data += 1
#for blue
if data_index < data_len:
pixel[0] = int(b[:-1] + binary_secret_data[data_index], 2)
data_index += 1
if data_index >= data_len:
break
我收到此错误:
Traceback (most recent call last):
File "image.py", line 14, in <module>
for row in image:
TypeError: 'PngImageFile' object is not iterable
一些建议请