def binaire2image(binaires):
r = 100
while True:
try:
c = len(binaires) // 8 // r
v = [binaires[i:i+8] for i in range(0, len(binaires), 8)]
d = [int(n, 2) for n in v]
arr = np.array(d).reshape((r, c))
image = Image.fromarray(arr.astype(np.uint8), mode='L')
return image
except ValueError:
r += 1
Please how can I get the original image from the binary string , without any information about the size .This code gives an unclear image . If I put a value close to the r "row" of the original image which is 180 , it gives the correct result , but if I don't have any idea about the image ?