def encoding(self): encode(self.fileLocation, self.encodeData, self.outputFileName) messagebox.showinfo( "Complete", 'Steganographier have encrypted the image successfully! The file is located at \n' + self.outputFileName) self.lblProgramName['text'] = "Encryption Completed" self.lblSelectText.lower(self.frame) self.lblOutputFileName.lower(self.frame) self.lblShowSelectInput.lower(self.frame) self.btnNextProcess.lower(self.frame) self.textOutputFileName.lower(self.frame) originalImg = Image.open(self.fileLocation) # resize the image and apply a high-quality down sampling filter originalImg = originalImg.resize((210, 210), Image.ANTIALIAS) # PhotoImage class is used to add image to widgets, icons etc originalImg = ImageTk.PhotoImage(originalImg) self.lblShowOriginal = tk.Label(self.root, image=originalImg, bg="white") self.lblShowOriginal.image = originalImg self.lblShowOriginal.place(relwidth=0.3, relheight=0.3, relx=0.15, rely=0.35) # opens the image encryptImg = Image.open(self.outputFileName) # resize the image and apply a high-quality down sampling filter encryptImg = encryptImg.resize((210, 210), Image.ANTIALIAS) # PhotoImage class is used to add image to widgets, icons etc encryptImg = ImageTk.PhotoImage(encryptImg) self.lblShowEncrypted = tk.Label(self.root, image=encryptImg, bg="white") self.lblShowEncrypted.image = encryptImg self.lblShowEncrypted.place(relwidth=0.3, relheight=0.3, relx=0.55, rely=0.35) self.lblOriginalText = tk.Label(text="Original Photo", font=("Helvetica", 16), bg="white") self.lblOriginalText.place(relwidth=0.3, relheight=0.08, relx=0.15, rely=0.65) self.lblEncryptedText = tk.Label(text="Encrypted Photo", font=("Helvetica", 16), bg="white") self.lblEncryptedText.place(relwidth=0.3, relheight=0.08, relx=0.55, rely=0.65) self.btnHome.lift(self.frame)
def save(self): self.drawWindow.destroy() filename = 'image.png' # image_number increments by 1 at every save self.image1.save(filename) img = Image.open(filename) img = self.process_img(img) idx = model.predict(img) print(idx) showImage = Image.open('letters/' + str(idx) + '.png') showImage.show()
def reconfigure_button(self, http_session, btn, url, img_url): global root filename = get_filename(img_url) dot_pos = filename.rfind('.') filename = filename[:dot_pos] bg_color = "green" image = self.get_from_cache(filename) if (image is None) or (len(image) == 0): image = download_image(http_session, img_url) self.put_to_cache(filename, image) bg_color = "red" if (image is None) or (len(image) == 0): return img = Image.open(io.BytesIO(image)) w, h = img.size k = IMG_WIDTH / w img_resized = img.resize((IMG_WIDTH, int(h * k))) photo_image = ImageTk.PhotoImage(img_resized) if photo_image is None: return root.after_idle(btn.set_values, url, partial(self.load_page_in_thread, url), photo_image, bg_color)
def item_selected(event): selected = event.widget.selection() for idx in selected: nombreTabla = treeview.item(idx)['text'] nombreBaseDatos = treeview.item(idx)['tags'][0] registros = Crud.extractTable(nombreBaseDatos, nombreTabla) for i in treeRegs.get_children(): treeRegs.delete(i) if registros: columnas = len(registros[0]) t = [] for c in range(0, columnas): t.append("Col_" + str(c)) treeRegs["columns"] = t treeRegs.column("#0", width=0, minwidth=0, stretch=tk.NO) for i in treeRegs["columns"]: treeRegs.column(i, width=200, stretch=tk.NO) treeRegs.heading(i, text=i.title(), anchor=tk.W) mColor = 'par' for reg in registros: treeRegs.insert("", tk.END, values=reg, tags=(mColor, )) if mColor == 'par': mColor = 'impar' else: mColor = 'par' url = str(pathlib.Path().absolute()) img = Image.open(url + "\\imagenes\\graficaArboles\\" + nombreTabla + ".png") photo = ImageTk.PhotoImage(img) lab = Label(image=photo).place(x=310, y=10) update_idletasks()
def load_original_image(self): response = requests.get(self.image_url, proxies=self.proxies, timeout=TIMEOUT) if response.status_code == 404: print("image_url response.status_code == 404") return self.original_image = response.content # if DEBUG: # with open(self.original_image_name, 'wb') as f: # f.write(self.original_image) self.put_to_cache(self.original_image_name, self.original_image) bg_color = 'red' self.resized = True img = Image.open(io.BytesIO(self.original_image)) w, h = img.size k = MAIN_IMG_WIDTH / w img_resized = img.resize((MAIN_IMG_WIDTH, int(h * k))) root.after_idle(root.title, f"{root.title()} ({w}x{h})") self.main_image_orig = ImageTk.PhotoImage(img) self.main_image = ImageTk.PhotoImage(img_resized) root.after_idle(self.btn_image.config, { 'image': self.main_image, 'background': bg_color })
def anonmeyes(imagepath, picture): picture = os.path.join(imagepath, picture) image = Image.open(picture) data = list(image.getdata()) image_no_exif = Image.new(image.mode, image.size) image_no_exif.putdata(data) randomstring = str(uuid.uuid4()) filename = os.path.join(imagepath + '/cleaned', randomstring + '.png') image_no_exif.save(filename) prototxtPath = resource_path("deploy.prototxt") weightsPath = resource_path("res10_300x300_ssd_iter_140000.caffemodel") net = cv2.dnn.readNet(prototxtPath, weightsPath) # load the input image from disk, clone it, and grab dimensions image.close() image = cv2.imread(filename) orig = image.copy() (h, w) = image.shape[:2] # construct a blob from the image blob = cv2.dnn.blobFromImage(image, 1.0, (300, 300), (104.0, 177.0, 123.0)) net.setInput(blob) detections = net.forward() # loop over the detections for i in range(0, detections.shape[2]): confidence = detections[0, 0, i, 2] # filter out weak detections if confidence > 0.3: # compute the (x, y)-coordinates of the bounding box for the # object box = detections[0, 0, i, 3:7] * np.array([w, h, w, h]) (startX, startY, endX, endY) = box.astype("int") # extract the face ROI face = image[startY:endY, startX:endX] face = anonymize_face_pixelate(face, blocks=12) # store the blurred face in the output image image[startY:endY, startX:endX] = face os.remove(filename) cv2.imwrite(filename, image) loadfile = str(filename) change_image(loadfile) root.update() return filename
def analog_drag(self): # 刷新一下极验图片 element = self.driver.find_element_by_xpath( '//a[@class="geetest_refresh_1"]') element.click() time.sleep(1) # 保存两张图片 self.save_img('full.jpg', 'geetest_canvas_fullbg') self.save_img('cut.jpg', 'geetest_canvas_bg') full_image = Image.open('full.jpg') cut_image = Image.open('cut.jpg') # # 根据两个图片计算距离 distance = self.get_offset_distance(cut_image, full_image) # 开始移动 self.start_move(distance) # 如果出现error try: WebDriverWait(self.driver, 5, 0.5).until( EC.presence_of_element_located( (By.XPATH, '//div[@class="geetest_slider geetest_error"]'))) print("验证失败") return except TimeoutException as e: pass # 判断是否验证成功 try: WebDriverWait(self.driver, 10, 0.5).until( EC.presence_of_element_located( (By.XPATH, '//div[@class="geetest_slider geetest_success"]'))) except TimeoutException: print("again times") self.analog_drag() else: print("验证成功")
def get_prediction(img_path, threshold): img = Image.open(img_path) # Load the image transform = T.Compose([T.ToTensor()]) # Defing PyTorch Transform img = transform(img) # Apply the transform to the image pred = model([img]) # Pass the image to the model pred_class = [COCO_INSTANCE_CATEGORY_NAMES[i] for i in list(pred[0]['labels'].numpy())] # Get the Prediction Score pred_boxes = [[(i[0], i[1]), (i[2], i[3])] for i in list(pred[0]['boxes'].detach().numpy())] # Bounding boxes pred_score = list(pred[0]['scores'].detach().numpy()) pred_t = [pred_score.index(x) for x in pred_score if x > threshold][-1] # Get list of index with score greater than threshold. pred_boxes = pred_boxes[:pred_t+1] pred_class = pred_class[:pred_t+1] return pred_boxes, pred_class
def save_picture(form_picture): random_hex = secrets.token_hex() _, f_ext = os.path.splitext(form_picture.filename) picture_fn = random_hex + f_ext picture_path = os.path.join(app.root_path, 'static/profile_pics', picture_fn) output_size = (125, 125) i = Image.open(form_picture) i.thumbnail(output_size) form_picture.save(picture_path) return picture_fn
def main(self): #Enabling the foreign key support self.QUERY = "PRAGMA foreign_keys = ON" self.cursor.execute(self.QUERY) self.conn.commit() #Setting the icon of the file image = ImageTk.PhotoImage(Image.open('./logo.ico')) self.root.iconphoto(False, image) self.loginFrame() self.root.mainloop()
def get_result(image_path): new_model = load_model("covid_model.h5") new_model.summary() img_width, img_height = 224, 224 img = image.load_img(image_path, target_size=(img_width, img_height)) x = image.img_to_array(img) img = np.expand_dims(x, axis=0) pred = new_model.predict(img) print(pred) # норм тут print(np.argmax(pred, axis=1)) prediction = np.argmax(pred, axis=1) im = Image.open(image_path) resized = im.resize((350, 400), Image.ANTIALIAS) resized.save("result.jpg") print_on_image = '' if prediction == 0: print_on_image = 'Covid-19' else: print_on_image = 'Non_Covid-19' image_cv = cv2.imread("result.jpg") output = image_cv.copy() cv2.putText(output, print_on_image, (10, 390), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 3) cv2.imwrite("result_name.jpg", output) #gif1 = PhotoImage(file="result_name.gif") #canvas.create_image(244, 244, image=gif1, anchor=NW) new_image = Image.open("result_name.jpg") tkimage = ImageTk.PhotoImage(new_image) imag_e.config(image=tkimage) imag_e.image = tkimage imag_e.pack(side="bottom", fill="both", expand="yes")
def load_image(self): try: with opener.open(self.img_url) as f: raw_data = f.read() content = io.BytesIO(raw_data) img = Image.open(content) self.model_image = ImageTk.PhotoImage(img) self.image_label.config(image=self.model_image) except BaseException as e: logger.exception(e) self.master.update_idletasks() self.master.after(DELAY, self.load_image)
def fetch_image(self): global root try: response = self.http_session.get(self.img_url, timeout=TIMEOUT) img = Image.open(io.BytesIO(response.content)) w, h = img.size k = 200 / w img_resized = img.resize((200, int(h * k))) root.after_idle(self.update_image, img_resized) except BaseException as error: root.after_idle(self.set_undefined_state) print("Exception URL: " + self.img_url) print(error) traceback.print_exc()
def getImageWithID(path): imagePaths = [os.path.join(path, f) for f in os.listdir(path)] # print(imagePaths) #in duong dan anh faces = [] IDs = [] # chuyen doi anh thanh ma tran for imagePath in imagePaths: faceImg = Image.open(imagePath).convert('L') faceNp = np.array(faceImg, 'uint8') #lay du lieu anh print(faceNp) #in anh ve dang array get_Id = int(imagePath.split('.')[1]) #lay du lieu ID print("\ngetid=", get_Id) faces.append(faceNp) IDs.append(get_Id) cv2.imshow('trainning', faceNp) cv2.waitKey(10) return faces, IDs
def save(): # global image_number img_pkl_number = pickle.load(open("save.p", "rb")) filename = f'img_{img_pkl_number}.bmp' # save the file image1.save(filename) # resize the image based on the width (REQUIRED TO BE SQUARE) basewidth = 28 img = Image.open(filename) wpercent = (basewidth / float(img.size[0])) hsize = int((float(img.size[1]) * float(wpercent))) img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS) img.save(filename) img_pkl_number += 1 pickle.dump(img_pkl_number, open("save.p", "wb")) # LINE ONLY TO KEEP IMAGES AT 0 restart()
def set_Image(self): self.fileLocation = self.open_file() if self.fileLocation: # opens the image img = Image.open(self.fileLocation) # resize the image and apply a high-quality down sampling filter img = img.resize((400, 400), Image.ANTIALIAS) # PhotoImage class is used to add image to widgets, icons etc img = ImageTk.PhotoImage(img) # create a label self.lblShowPanel = tk.Label(self.root, image=img, bg="white") self.lblShowPanel.image = img self.lblShowPanel.place(relwidth=0.6, relheight=0.5, relx=0.2, rely=0.3) self.lblProgramName['text'] = "Photo Selected" self.lblSelectText.lower(self.frame) self.btnNextProcess.lift(self.frame) self.btnFileSelectInput.lower(self.frame)
def click(): filename = filedialog.askopenfilename(initialdir='/images/', title='Searching', filetypes=(("jpg files", "*.jpg"), ("png files", "*.png"))) path = filename images = {} for fname in glob.glob(path): img = cv2.imread(fname) avg_row = numpy.average(img, axis=0) avg_color = numpy.uint8(numpy.average(avg_row, axis=0)) images[fname] = avg_color.tolist() img = pd.DataFrame.from_dict(data=images, orient='index') img.columns = ['blue', 'green', 'red'] print(img.head(), sum(images[fname])) img = Image.open(filename) width, height = img.size img = img.resize((round(350 / height * width), round(350))) tkimage = ImageTk.PhotoImage(img) myvar = Label(root, image=tkimage) myvar.image = tkimage myvar.grid(row=2, column=0, columnspan=2, padx=10, pady=10) if sum(images[fname]) >= 504 and sum(images[fname]) <= 512: label_result = Label(root, text="Result : 500 MMK") label_result.grid(row=3, column=0, columnspan=2, pady=20) elif sum(images[fname]) >= 466 and sum(images[fname]) <= 498: label_result = Label(root, text="Result : 1000 MMK") label_result.grid(row=3, column=0, columnspan=2) elif sum(images[fname]) >= 521 and sum(images[fname]) <= 582: label_result = Label(root, text="Result : 5000 MMK") label_result.grid(row=3, column=0, columnspan=2) else: label_result = Label(root, text="Not Found") label_result.grid(row=3, column=0, columnspan=2)
def compute(): # load the "trained" NN weights and biases weight_HL = 0 weight_OL = 0 bias_HL = 0 bias_OL = 0 weight_HL, weight_OL, bias_HL, bias_OL = pickle.load( open("weights_bias.p", "rb")) # load the image into a matrix image_vector = [] img = Image.open(r'C:\Users\Josro\Documents\GitHub\IA_croquis' + '\\' + 'img_0.bmp') gray = img.convert('L') black_white = numpy.asarray(gray).copy() single_array = numpy.concatenate(black_white, axis=None) image_vector.append(single_array) image_matrix = numpy.asarray(image_vector) IHL, HLA, OCP, predicciones = feed_forward2(image_matrix, weight_HL, weight_OL, bias_HL, bias_OL) check = numpy.array(('arbol', 'casa', 'circulo', 'cuadrado', 'feliz', 'huevo', 'mickey', 'qmark', 'triste')) predicciones = numpy.squeeze(predicciones) solucion = numpy.stack((check, predicciones)) print(solucion.T)
def render_page(self, ident, html, http_session): self.thumb_url = get_thumb(html) if (self.thumb_url is None) or (len(self.thumb_url) == 0): print("len(thumb_url) == 0") return False slash_pos = self.thumb_url.rfind('/') self.thumb_prefix = self.thumb_url[:slash_pos + 1] thumb_filename = self.thumb_url[slash_pos + 1:] dot_pos = thumb_filename.rfind('.') thumb_filename = thumb_filename[:dot_pos] self.gallery_url = search('href="([^"]*)">More from gallery</a>', html) self.reconfigure_prev_button(http_session, html) self.reconfigure_next_button(http_session, html) executor.submit(self.reconfigure_left_buttons, html) executor.submit(self.reconfigure_right_buttons, html) self.image_url = self.provider.get_image_url(html) fname = get_filename(self.image_url) dot_pos = fname.rfind('.') self.original_image_name = fname[:dot_pos] + '_' + ident self.original_image = self.get_from_cache(self.original_image_name) bg_color = 'green' self.resized = True if (self.original_image is None) or (len(self.original_image) == 0): self.original_image = self.get_from_cache(thumb_filename) self.resized = False if (self.original_image is None) or (len(self.original_image) == 0): response = http_session.get(self.thumb_url, proxies=self.proxies, timeout=TIMEOUT) if response.status_code == 404: print("image_url response.status_code == 404") return False self.original_image = response.content # if DEBUG: # with open(self.original_image_name, 'wb') as f: # f.write(self.original_image) self.put_to_cache(thumb_filename, self.original_image) bg_color = 'red' self.resized = False img = Image.open(io.BytesIO(self.original_image)) w, h = img.size k = MAIN_IMG_WIDTH / w img_resized = img.resize((MAIN_IMG_WIDTH, int(h * k))) root.after_idle(root.title, f"{root.title()} ({w}x{h})") self.main_image_orig = ImageTk.PhotoImage(img) self.main_image = ImageTk.PhotoImage(img_resized) photo_image = self.main_image if self.resized else self.main_image_orig root.after_idle(self.btn_image.config, { 'image': photo_image, 'background': bg_color }) if os.path.exists(os.path.join(OUTPUT, self.original_image_name)): root.after_idle(self.btn_save.config, {'background': 'green'}) return True
DRIVER_PATH = 'C:\chromedriver\chromedriver.exe' options = Options() options.headless = True options.add_argument("--window-size=1920,1200") driver = webdriver.Chrome(options=options, executable_path=DRIVER_PATH) #driver.get("https://www.nintendo.com/") driver.get( "https://www.juegosinfantilespum.com/laberintos-online/12-auto-buhos.php") time.sleep(10) element = driver.find_element_by_xpath( "/html/body/div/div[1]/div[1]/div[1]/canvas") element.click() driver.set_window_size(639, 321) # May need manual adjustment 639,325 driver.find_element_by_tag_name('canvas').screenshot('web_screenshot.png') driver.quit() #os.getcwd() img = Image.open("web_screenshot.png") border = (7, 31, 0, 0) # left, up, right, bottom newIMG = ImageOps.crop(img, border) newIMG.save("nivel1.png") newIMG.show() remove(os.getcwd() + '\web_screenshot.png')
def GraficaBasesDatos(): url = str(pathlib.Path().absolute()) img = Image.open(url + "\\imagenes\\graficaArboles\\BBDD.png") photo = ImageTk.PhotoImage(img) lab = Label(image=photo).place(x=310, y=10) update_idletasks()
#截图存放位置 screenImg="F:\cxl\script\0python_script\MeiCai\screenImg\screen.png" #截图 driver.get_screenshot_as_file(r'F:\cxl\script\0python_script\MeiCai\screenImg\screen.png') # 定位验证码位置及大小 location=driver.find_element_by_id('yw0').location size=driver.find_element_by_id('yw0').size left = location['x'] top = location['y'] right = location['x'] + size['width'] bottom = location['y'] + size['height'] # 从文件读取截图,截取验证码位置再次保存 img = Image.open(screenImg).crop((left, top, right, bottom)) #下面对图片做了一些处理,能更好识别一些,相关处理再百度看吧 img = img.convert('RGBA') # 转换模式:L | RGB img = img.convert('L') # 转换模式:L | RGB # img = ImageEnhance.Contrast(img) # 增强对比度 img = img.enhance(2.0) # 增加饱和度 img.save(screenImg) # 再次读取识别验证码 img = Image.open(screenImg) code = pytesseract.image_to_string(img) #打印识别的验证码 #print(code.strip()) #### driver.quit()
miAplicacion = Tk() miAplicacion.minsize(1200, 700) miAplicacion.maxsize(1200, 700) menubar = Menu(miAplicacion) help = Menu(menubar, tearoff=0) help.add_command(label="About", command=About) help.add_separator() help.add_command(label="Grafica Bases de Datos", command=GraficaBasesDatos) help.add_separator() help.add_command(label="Exit", command=miAplicacion.quit) menubar.add_cascade(label="Help", menu=help) miAplicacion.config(menu=menubar) treeview = ttk.Treeview(selectmode=tk.BROWSE) treeview.place(x=10, y=10) treeview.heading("#0", text="TytusDB - Modo AVL") treeview.tag_bind("mytag", "<<TreeviewSelect>>", item_selected) treeRegs = ttk.Treeview(selectmode=tk.BROWSE) treeRegs.place(x=10, y=410) treeRegs.tag_configure('par', background='white', foreground='black') treeRegs.tag_configure('impar', background='black', foreground='white') img = Image.open("imgTytus.png") photo = ImageTk.PhotoImage(img) lab = Label(image=photo).place(x=310, y=10) CargarDatos() miAplicacion.mainloop()
from tkinter import Image from PIL import Image, ImageFilter import numpy as np from matplotlib import pyplot as plt from PIL import Image import sys img = Image.open("Foto/foto.png") img = img.convert("RGBA") from PIL import Image imagePath = "Foto/foto.png" #newImagePath = 'A:\ex2.jpg' im = Image.open(imagePath) def redOrBlack (im): newimdata = [] redcolor = (0, 0, 0) redcolor1 = (105, 105, 105) blackcolor = (255,0,0) for color in im.getdata(): if color >= redcolor or color <= redcolor1: newimdata.append( (0,125,0) ) else: newimdata.append( color) newim = Image.new(im.mode,im.size) newim.putdata(newimdata) return newim
#all the imports from tkinter import Tk,TRUE,FALSE,Label,Frame,Button,COMMAND,Image,mainloop,PhotoImage,FLAT,TOP,LEFT,BOTH from base import export_func,import_func,run_func from PIL import Image from PIL import ImageTk main=Tk() #title main.title("Filent") main.geometry("700x400") #icon mainicon=Image.open('icon.png') mainicon=mainicon.resize((94,94)) mainicon=ImageTk.PhotoImage(mainicon) main.iconphoto(False,mainicon) #background image = Image.open('image.png') image = image.resize((3840,2160)) img = ImageTk.PhotoImage(image) mainframe=Label(image=img) #button images import_image=Image.open("import.png") import_image=ImageTk.PhotoImage(import_image) export_image=Image.open("export.png") export_image=ImageTk.PhotoImage(export_image)
def canvas(): global win global frame global x global y global x_vel global y_vel global a global b global a_vel global b_vel global m global n global m_vel global n_vel global r global s global r_vel global s_vel def move(): # get random move for the bubbles x_vel = random.randint(-5, 5) y_vel = -5 a_vel = random.randint(-7, 4) b_vel = -7 m_vel = random.randint(-6, 5) n_vel = -2 r_vel = random.randint(-4, 4) s_vel = -5 canvas1.move(circle, x_vel, y_vel) canvas1.move(circle2, a_vel, b_vel) canvas1.move(circle3, m_vel, n_vel) canvas1.move(circle4, r_vel, s_vel) coordinates = canvas1.coords(circle) x = coordinates[0] y = coordinates[1] a = coordinates[0] b = coordinates[1] m = coordinates[0] n = coordinates[1] r = coordinates[0] s = coordinates[1] # if outside screen move to start position if y < -height: x = start_x y = start_y canvas1.coords(circle, x, y, x + width, y + height) #window.after(33, move) if b < -height: a = start_a b = start_b canvas1.coords(circle2, a, b, a + width2, b + height2) if s < -height: r = start_r s = start_s canvas1.coords(circle4, r, s, r + width4, s + height4) if n < -height: m = start_m n = start_n canvas1.coords(circle3, m, n, m + width3, n + height3) frame.after(30, move) # make bubbles start at different positions start_x = 170 start_y = 140 start_a = 230 start_b = 140 start_m = 290 start_n = 140 start_r = 300 start_s = 140 x = start_x y = start_y a = start_a b = start_b m = start_m n = start_n r = start_r s = start_s # create different sized bubbles width = 20 height = 20 width2 = 29 height2 = 29 width3 = 15 height3 = 15 width4 = 30 height4 = 30 x_vel = 5 y_vel = 5 a_vel = 5 b_vel = 5 m_vel = 5 n_vel = 5 r_vel = 5 s_vel = 5 if (frame != None): frame.destroy() frame = Frame(win) #canvas canvas1 = tk.Canvas(frame, height=1000, width=1000) canvas1.grid(row=0, column=0, sticky='w') coord = [x, y, x + width, y + height] circle = canvas1.create_oval(coord, outline="light blue", fill="light blue") coord = [a, b, a + width2, b + height2] circle2 = canvas1.create_oval(coord, outline="cyan", fill="cyan") coord = [m, n, m + width3, n + height3] circle3 = canvas1.create_oval(coord, outline="DarkSlateGray1", fill="darkslategray1") coord = [r, s, r + width4, s + height4] circle4 = canvas1.create_oval(coord, outline="paleturquoise", fill="paleturquoise") coord = [x, y, x + 160, y + 10] rect2 = canvas1.create_rectangle(coord, outline="goldenrod", fill="goldenrod") coord = [150, 40, 170, 320] rect = canvas1.create_rectangle(coord, outline="Black", fill="Black") coord = [330, 40, 350, 310] rect1 = canvas1.create_rectangle(coord, outline="Black", fill="black") coord = [130, 310, 370, 320] rect2 = canvas1.create_rectangle(coord, outline="Blue", fill="Blue") coord = [230, 270, 270, 310] rect3 = canvas1.create_rectangle(coord, outline="purple", fill="purple") # reseize image using PILLOW library load = Image.open('flame1.png') load = load.resize((17, 27), Image.ANTIALIAS) render = ImageTk.PhotoImage(load) # position image img = Label(image=render) img.image = render img.place(x=240, y=240) # reseize image load1 = Image.open('termo.png') load1 = load1.resize((17, 170), Image.ANTIALIAS) render1 = ImageTk.PhotoImage(load1) # position image img1 = Label(image=render1) img1.image = render1 img1.place(x=240, y=10) btnHome = Button(frame, text="Home", command=createMainMenuGUI, height=2, width=8, fg="black", bg="green4", font=("Comic Sans MS", 10)) btnHome.place(x=320, y=330) btnAnswer = Button(frame, text="ANSWER", command=answerGUI, height=2, width=8, fg="black", bg="green4", font=("Comic Sans MS", 10)) btnAnswer.place(x=320, y=370) #top left x and y coordinates and bottom right x and y coordinates coord = [200, 150, 210, 240] rect4 = canvas1.create_rectangle(coord, outline="gray30", fill="gray30") coord = [210, 230, 300, 240] rect4 = canvas1.create_rectangle(coord, outline="gray30", fill="gray30") coord = [290, 150, 300, 240] rect4 = canvas1.create_rectangle(coord, outline="gray30", fill="gray30") coord = [240, 20, 260, 180] rect4 = canvas1.create_rectangle(coord, outline="Pink", fill="pink") move() frame.pack()
label_ids = {} for root, dirs, files in os.walk(img_dir): for file in files: if file.endswith("png") or file.endswith("jpeg") or file.endswith( "jpg"): path = os.path.join(root, file) label = os.path.basename(root).replace(" ", "_").lower() #print(label,path) if not label in label_ids: label_ids[label] = current_id current_id = current_id + 1 id_ = label_ids[label] #print(label_ids) pil_image = Image.open(path).convert("L") size = (550, 550) final_image = pil_image.resize(size, Image.ANTIALIAS) image_array = np.array(final_image, "uint8") #print(image_array) faces = face_cascade.detectMultiScale(image_array, scaleFactor=1.15, minNeighbors=5) for (x, y, w, h) in faces: roi = image_array[y:y + h, x:x + w] x_train.append(roi) y_label.append(id_) #print(y_label) #print(x_train)
from tkinter import Image from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.support.ui import Select driver = webdriver.Chrome( executable_path= "C://Users//Nani Madhan//Downloads//chromedriver_win32//chromedriver.exe") driver.get("https://www.testandquiz.com/selenium/testing.html") driver.maximize_window() driver.implicitly_wait(3) select = Select( driver.find_element_by_xpath('/html/body/div/div[9]/div/p/select')) # select by visible text # select.select_by_visible_text('Manual Testing') # select by value #select.select_by_value('3') select.select_by_index('2') driver.save_screenshot("image.png") image = Image.open("image.png") image.show()
parser.add_argument("-t", "--thread", help="enter number of thread ", type=int) parser.add_argument("--G", help="Graphical Interface ") args = parser.parse_args() # For Graphical Interface :::: if (args.G): root = tk.Tk() root.geometry('700x400') root.title("Dos Attack") root.configure(bg='black') # Images :::::::: img = ImageTk.PhotoImage(Image.open('hck5.jpg')) panel = Label(root, image=img) one_btn = Label(root, image=img) one_btn.grid(row=0, column=0) img2 = ImageTk.PhotoImage(Image.open('dosimg2.jpg')) panel1 = Label(root, image=img2) one_btn1 = Label(root, image=img2) one_btn1.grid(row=0, column=1, columnspan=3) # Labeles ::::::: website_label = ttk.Label(root, text="Enter Web site : ") website_label.grid(row=1, column=0, padx=8, pady=8, sticky=tk.W)
def get_image(self, filename, width, height): im = Image.open(filename).size(width, height) return ImageTk.PhotoImage(im)