diff --git a/README.md b/README.md index 32ca216..59e6eaf 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ pillow numpy ## run -python main.py +python src/Main.py ## menu items * file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0e0efb4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pillow~=11.3.0 +numpy~=2.3.1 diff --git a/src/GUI.py b/src/GUI.py index e15cb09..20718a4 100644 --- a/src/GUI.py +++ b/src/GUI.py @@ -2,6 +2,7 @@ import tkinter as tk from tkinter import filedialog from PIL import ImageTk from ImageContainer import ImageContainer +from ImageManipulation.ManipulationList import * class GUI: @@ -47,54 +48,11 @@ class GUI: file_menu.add_command(label="Save Image", command=lambda: _save_image(OPENED_IMAGE)) file_menu.add_command(label="Exit", command=root.quit) + test_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Test", menu=test_menu) - test_menu.add_command(label="Padding", command=lambda: padding(OPENED_IMAGE, - border_width=50) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Crop", command=lambda: crop(OPENED_IMAGE) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Resize", - command=lambda: resize(OPENED_IMAGE) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Copy", command=lambda: copy(OPENED_IMAGE) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Greyscale", - command=lambda: grayscale(OPENED_IMAGE) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Hsv", command=lambda: hsv(OPENED_IMAGE) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Hue Shifted", - command=lambda: hue_shifted(OPENED_IMAGE, hue=50) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Smoothed", - command=lambda: smoothing(OPENED_IMAGE) if OPENED_IMAGE is not None else print( - "No image opened.")) - test_menu.add_command(label="Rotated", command=lambda: rotation(OPENED_IMAGE, - rotation_angle=90) if OPENED_IMAGE is not None else print( - "No image opened.")) - - clipboard_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Clipboard", menu=clipboard_menu) - - image_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Image", menu=image_menu) - - tools_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Tools", menu=tools_menu) - - shapes_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Shapes", menu=shapes_menu) - - colors_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Colors", menu=colors_menu) - - layer_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Layer", menu=layer_menu) - - filter_menu = tk.Menu(menu, tearoff=0) - menu.add_cascade(label="Filter", menu=filter_menu) - # + menu.add_cascade(label="Filters", menu=test_menu) + for manipulation in GetImageManipulationList(): + test_menu.add_command(label=manipulation.getManipulationName(), command=lambda: manipulation.manipulateImage()) # Frame to hold image imgframe = tk.Frame(root, width=500, height=500, bg="lightgray", relief="sunken", bd=2) diff --git a/src/ImageManipulation/CropImage.py b/src/ImageManipulation/CropImage.py new file mode 100644 index 0000000..2f63014 --- /dev/null +++ b/src/ImageManipulation/CropImage.py @@ -0,0 +1,39 @@ +from .ImageManipulation import ImageManipulation +from ..ImageContainer import ImageContainer +from typing import Any, List + + +class CropImage(ImageManipulation): + """Concrete implementation for cropping images.""" + + def __init__(self): + # You can initialize any instance variables here + self.manipulation_name = "Crop" + + def manipulateImage(self, image: ImageContainer, parameters: Any) -> None: + """ + Manipulate the given image using the provided parameters. + + Args: + image: The image to manipulate + parameters: Parameters for the manipulation (e.g., crop coordinates) + """ + pass + + def getParameters(self) -> List[str]: + """ + Get the list of parameters required for cropping. + + Returns: + List of parameter names + """ + return ["width", "height"] + + def getManipulationName(self) -> str: + """ + Get the name of this manipulation operation. + + Returns: + The name of the manipulation + """ + return "Crop Image" \ No newline at end of file diff --git a/src/ImageManipulation/ManipulationList.py b/src/ImageManipulation/ManipulationList.py new file mode 100644 index 0000000..aeff678 --- /dev/null +++ b/src/ImageManipulation/ManipulationList.py @@ -0,0 +1,4 @@ +from src.ImageManipulation.CropImage import * + +def GetImageManipulationList() -> list: + return [CropImage()] \ No newline at end of file diff --git a/src/Main.py b/src/Main.py index d9c6bbc..d79ee9f 100644 --- a/src/Main.py +++ b/src/Main.py @@ -1,3 +1,4 @@ +#!/usr/bin/python from GUI import GUI if __name__ == "__main__":