def addImage(self): try: self.image_name = fd.askopenfilename() save_image = ImageEditor() new_photopath = save_image.copyPhoto(self.image_name) self.text.insert(END, "\n\nimage*" + new_photopath) except Exception as e: print("caught in addImage: %s" % e)
def __init__(self, path, w, h, mode="Image", cascade=""): self.CAM = CameraMan(w, h) self.IE = ImageEditor() self.mode = mode if not mode == "norecord": self.IS = ImageStore(path, mode) if mode == "Movie": self.IS.movie_settings(w, h) self.CS = CsvStore(path) self.fps = FPS() self.cascade_path = cascade
def addMainImage(self): try: self.image_name = fd.askopenfilename() save_image = ImageEditor() if self.currFile == '': self.saveAsF() new_photopath = save_image.addMainPhoto(self.image_name, self.currFile) print("successfully saved %s." % new_photopath) except Exception as e: print("caught in addMainImage: %s" % e)
def scale(self): if os.path.isfile(self.currentImage): items = ('0.5', '0.7', '1.5') item, okPressed = QInputDialog.getItem(self, 'Resize image', 'Scale factor:', items, 0, False) if okPressed and item: print(item) self.pixmap = ImageEditor(self.currentImage).resize(item) self.image_label.setPixmap(self.pixmap) self.adjust_size()
def get_editor(self, **kwargs): """ Opens a new empty window """ editor = ImageEditor() return editor
def create_menu(self, img): padding = 5 img_orig = img img = img.copy() img.thumbnail((OptionsFrame.frame_width // 2 - padding * 3 - 10, OptionsFrame.frame_width // 2 - padding * 3 - 10)) image_editor_model = ImageEditor() image_editor_model.load_image(img) def on_effect_click(effect_fun): self.master.load_image_preview(effect_fun(img_orig)) self.master.crop_params = None def on_index(ind, event): on_effect_click(image_editor_model.get_effect(ind)[0]) accept_btn = tk.Button(self.scrollable_frame, text="Apply") accept_btn.grid(row=0, column=0, padx=padding, pady=padding, sticky="nesw") def on_apply(): if self.master.crop_params != None: print("cropping!") self.master.img = self.master.img.crop(self.master.crop_params) self.master.crop_params = None self.master.load_image(self.master.img) accept_btn['command'] = on_apply cancel_btn = tk.Button(self.scrollable_frame, text="Revert") cancel_btn.grid(row=0, column=1, padx=padding, pady=padding, sticky="nesw") def on_cancel(): self.master.load_options_prev(self.master.img_orig) self.master.load_image_preview(self.master.img_orig) cancel_btn['command'] = on_cancel for i, image_with_effect in enumerate( image_editor_model.get_images_with_effects()): thumbn_frame = tk.Frame(self.scrollable_frame, bg="black") thumbn_frame.grid(row=((i + 2) // 2), column=(i % 2), pady=padding, padx=padding, sticky="W") thumbn_frame.bind("<Button-1>", partial(on_index, i)) #image_with_effect[0].thumbnail((OptionsFrame.frame_width//2, OptionsFrame.frame_width//2)) img_tk = ImageTk.PhotoImage(image=image_with_effect[0]) thumbn_photo = tk.Label(thumbn_frame, text='image_here', image=img_tk) thumbn_photo.image = img_tk thumbn_photo.pack(side=tk.TOP) thumbn_photo.bind("<Button-1>", partial(on_index, i)) thumbn_name = tk.Label(thumbn_frame, text=image_with_effect[1]) thumbn_name.pack(side=tk.TOP) thumbn_name.bind("<Button-1>", partial(on_index, i))
def decode_from_file(filename): img = ImageEditor(filename) msg = img.extract_message() return msg
def encode_to_file(old_filename, png_filename, message): """Use ImageEditor to write message to image and save locally""" img = ImageEditor(old_filename) img.encode(message) os.remove(old_filename) img.save_changes(filename=png_filename)
def set_gray(self): if os.path.isfile(self.currentImage): self.pixmap = ImageEditor(self.currentImage).gray() self.image_label.setPixmap(self.pixmap) self.adjust_size()