Skip to content

Commit

Permalink
main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRezoc authored Oct 1, 2023
1 parent 01001bd commit 9eac54e
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions dce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import customtkinter as ctk
import matplotlib
from customtkinter import filedialog
import matplotlib.pyplot as plt
from colorthief import ColorThief

matplotlib.use('TkAgg')
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("dark-blue")


# Function to select the image for color extraction
def select_image():
try:
global selected_image
selected_image = filedialog.askopenfilename(filetypes=[("Image Files", "*.jpg;*.jpeg;*.png")])
ct = ColorThief(selected_image)
dominant_color = ct.get_color(quality=1)
status_label.configure(text="RGB: " + str(dominant_color))
plt.imshow([[dominant_color]])
plt.show()
except Exception as e:
print(f"Error: {str(e)}")


# Global variable to store the selected image path
selected_image = None

# Create the main customtkinter window
root = ctk.CTk()
root.title("Dominant Color Extractor")
root.geometry("375x130")
root.resizable(False, False)

frame = ctk.CTkFrame(master=root)
frame.pack(pady=10, padx=10, fill="both", expand=True)

select_button = ctk.CTkButton(master=frame, text="Select Image", command=select_image)
select_button.pack(pady=20, padx=10)

status_label = ctk.CTkLabel(master=frame, text="Please select an image.")
status_label.pack(pady=5, padx=10)


root.mainloop()

0 comments on commit 9eac54e

Please sign in to comment.