def run(self): # set up the gui window = tkinter.Tk() window.bind("<Button>", self.clicked) window.bind("<Key>", self.key_press) while not self.quit: if self.index < 0: self.index = len(self.img_list) - 1 if self.index >= len(self.img_list): self.index = 0 # print(self.index) window.title(self.img_list[self.index]) picture = imdirect_open(self.img_list[self.index]) picture_width = int(picture.size[0] / 5) picture_height = int(picture.size[1] / 5) picture = picture.resize((picture_width, picture_height), Image.ANTIALIAS) tk_picture = ImageTk.PhotoImage(picture) window.geometry("{}x{}+200+200".format(picture_width, picture_height)) image_widget = tkinter.Label(window, image=tk_picture) image_widget.place(x=0, y=0, width=picture_width, height=picture_height) # wait for events window.mainloop() window.destroy()
def post(self, request): if not hasattr(request.user, 'founder'): founder = Founder() founder.user = request.user founder.description = request.POST.get('description') #tz = pytz.timezone('Asia/Kolkata') #date = request.POST.get("date").replace("/", " ") #date = tz.localize( #dt=datetime.datetime.strptime(date, r'%d %m %Y') founder.save() name = str(uuid.uuid4()) data = request.POST.get('image') data = ContentFile(base64.b64decode(data), name=f'{name}.jpg') founder_img = FounderImage() founder_img.img = data founder_img.founder = request.user.founder founder_img.location = request.POST.get('location').title() #founder_img.date_found = date tz = pytz.timezone('Asia/Kolkata') # founder_img.date_found=tz.localize(dt=datetime.datetime.now()) founder_img.save() ab_path = os.path.join(dir_path, str(founder_img.img)) print(ab_path) image = imdirect.imdirect_open(ab_path) align_faces.align_face(ab_path) thread = threading.Thread(target=foundtesting, args=(founder_img, )) thread.start() return Response({})
def post(self, request): dir_path = "/Users/vishnuvarthan/Desktop/lostfound/media" if not hasattr(request.user, 'loser'): loser = Loser() loser.user = request.user loser.description = request.POST.get('description') loser.save() tz = pytz.timezone('Asia/Kolkata') #date = request.POST.get("date").replace("/", " ") #date = tz.localize(dt=datetime.datetime.strptime(date, r'%d %m %Y')) data = request.POST.get('image') name = str(uuid.uuid4()) data = ContentFile(base64.b64decode(data), name=f"{name}.jpg") loser_img = LoserImage() loser_img.img = data loser_img.loser = request.user.loser loser_img.location = request.POST.get('location').title() #loser_img.date_lost = date loser_img.save() ab_path = os.path.join(dir_path, str(loser_img.img)) align_faces.align_face(ab_path) print(ab_path) image = imdirect.imdirect_open(ab_path) print(loser_img.img) image.save(ab_path) thread = threading.Thread(target=losttesting, args=(loser_img, )) thread.start() return Response({})
def test_imdirect_open_with_string_path(): image_path = os.path.join(this_dir, 'testfile_6.jpg') img = Image.open(image_path) assert img.width == 300 assert img.height == 225 assert img._getexif().get(274) == 6 img_rot = imdirect.imdirect_open(image_path) assert img_rot.width == 225 assert img_rot.height == 300 assert img_rot._getexif().get(274) == 1
def test_imdirect_open_with_filelike(): image_path = os.path.join(this_dir, 'testfile_6.jpg') with open(image_path, 'rb') as f: img = Image.open(f) assert img.width == 300 assert img.height == 225 assert img._getexif().get(274) == 6 with open(image_path, 'rb') as f: img_rot = imdirect.imdirect_open(f) assert img_rot.width == 225 assert img_rot.height == 300 assert img_rot._getexif().get(274) == 1
def test_imdirect_3(): image_path, outpath = files(3, 'IMG_0862.jpg') img = Image.open(image_path) print(img.width, img.height, img._getexif().get(274)) assert img.width == 640 assert img.height == 480 assert img._getexif().get(274) == 3 img_rot = imdirect.imdirect_open(image_path) assert img_rot.width == 640 assert img_rot.height == 480 assert img_rot._getexif().get(274) == 1 img_rot.save(outpath)
run --- :copyright: 2016-08-30 by hbldh <*****@*****.**> """ from __future__ import division from __future__ import print_function from __future__ import unicode_literals from __future__ import absolute_import from PIL import Image import imdirect image_path = 'tests/testfile_6.jpg' img = Image.open(image_path) print("{0}, Orientation: {1}".format(img, img._getexif().get(274))) imdirect.monkey_patch() img_autorotated = Image.open(image_path) print("{0}, Orientation: {1}".format(img_autorotated, img_autorotated._getexif().get(274))) imdirect.monkey_patch(False) from imdirect import imdirect_open img = imdirect_open(image_path) print("{0}, Orientation: {1}".format(img, img._getexif().get(274)))