Пример #1
0
    def load_dest_img():
        global dest_img
        if imgs is None:
            return messagebox.showerror("Empty set",
                                        "Please first load source images")

        fp = filedialog.askopenfilename(
            initialdir=os.path.dirname(dest_img_path.get()) if os.path.isdir(
                os.path.dirname(dest_img_path.get())) else init_dir,
            title="Select destination image",
            filetypes=(("images", "*.jpg"), ("images", "*.png"),
                       ("images", "*.gif"), ("all files", "*.*")))
        if fp is not None and len(fp) > 0 and os.path.isfile(fp):
            try:
                print("Destination image loaded from", fp)
                dest_img = mkg.imread(fp)
                show_img(dest_img, False)
                dest_img_path.set(fp)
            except:
                messagebox.showerror("Error reading file",
                                     traceback.format_exc())
Пример #2
0
            canvas.configure(width=w, height=h)
            canvas.update()
            if result_img is not None:
                show_img(result_img, False)

    root.bind("<Configure>", canvas_resize)

    if cmd_args.D:

        def debug_act(fp):
            global imgs
            try:
                imgs = mkg.read_images(fp, (40, 40), True, 4, "center")
                grid = mkg.calc_grid_size(16, 10, len(imgs))
                return mkg.make_collage(grid, imgs, False)
            except:
                messagebox.showerror("Error", traceback.format_exc())

        file_path.set(cmd_args.src)
        print("Loading source images from", cmd_args.src)
        pool.submit(
            debug_act,
            cmd_args.src).add_done_callback(lambda f: show_img(f.result()))

        print("Destination image loaded from", cmd_args.collage)
        dest_img = mkg.imread(cmd_args.collage)
        show_img(dest_img, False)
        dest_img_path.set(cmd_args.collage)

    root.mainloop()