Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- #open the raw data file
- file = open("data.raw", "rb")
- data = file.read()
- file.close()
- #convert to array of integers
- data_array = []
- for item in data:
- data_array.append(int(item))
- #create new image
- image = Image.new("RGB", (232, 245))
- #set offset
- pixel=23
- #iterate through each pixel in the image, setting as appropriate based on data_array contents
- for y in range(245):
- for x in range(232):
- image.putpixel((x, y), (data_array[pixel], data_array[pixel+1], data_array[pixel+2]))
- pixel += 3
- #export image as png
- image.save("data.png")
Advertisement
Add Comment
Please, Sign In to add comment