Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- import os.path
- import io
- import PIL
- from PIL import Image, ImageDraw
- input_dir = r"C:\Users\Andrew\Desktop\\"
- input_file = r"SPeech.docx"
- input_full = input_dir + "" + input_file
- f = open(input_full, "rb")
- ba = bytearray(f.read())
- f_Size = len(ba)
- width = int(round(math.sqrt(f_Size),0))
- height = int(round((f_Size) / width,0) - 1)
- comp = Image.new("RGB", (width, height), "white")
- d = ImageDraw.Draw(comp)
- i = 0
- while i < height:
- j = 0
- while j < width:
- count = j*3+i*width
- if(count < f_Size-2):
- d.point((j,i), fill=(ba[count],ba[count+1],ba[count+2],255))
- j+=1
- i+=1
- comp.show()
- comp.save(input_file + 'File_To_Pic.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement