-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageWork.py
65 lines (43 loc) · 1.33 KB
/
ImageWork.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import cgi, requests, json, base64, PIL, re, uuid, os, sys
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
requests.packages.urllib3.disable_warnings()
from requests.auth import HTTPBasicAuth
from io import BytesIO
import grequests as async
# Used for the storeMemory function.
buff = BytesIO()
def storeMemory(item):
# Use cStringIO to write the item to memory.
buff.write(item)
# Go back to the start of the item.
buff.seek(0)
# Return the item we just stored.
return buff.getvalue()
def create_test_image():
file = BytesIO()
image = Image.new('RGBA', size=(50, 50), color=(155, 0, 0))
image.save(file, 'png')
file.name = 'test.png'
file.seek(0)
return file
# This is the path for the floorplan image files should be stored.
image_path = "./images/"
image_name = 'FloorPlanCopy.png'
if os.path.isfile(image_path + image_name ) == True:
print("File is here")
file = image_path + image_name
fh = open(file, "rb")
print("Stand by")
# image = storeMemory(fh.read()).b64encode("base64").strip()
print("Exited")
fh.close()
else:
print("File is not here")
#create_test_image()
img = mpimg.imread(image_path + image_name)
print(img)
imgplot = plt.imshow(img)
print("Image shown")