Merge pull request #7 from UiA-IKT213-Gruppe4/main

Snapchat filters
This commit is contained in:
Moira Daniella sebastian
2025-11-03 20:12:08 +01:00
committed by GitHub
16 changed files with 95 additions and 254 deletions

View File

@@ -62,26 +62,6 @@ class GUI:
command=partial(self._applyManipulation, manipulation)
)
# Manual Test menu listing all manipulations explicitly
# manual_menu = tk.Menu(menu, tearoff=0)
# menu.add_cascade(label="Test", menu=manual_menu)
# manual_menu.add_command(label="Padding", command=partial(self._applyManipulation, Padding(), {"border_width": 50}))
# manual_menu.add_command(label="Crop", command=partial(self._applyManipulation, CropImage()))
# manual_menu.add_command(label="Resize", command=partial(self._applyManipulation, ResizeImage(), {"width": 200, "height": 200}))
# manual_menu.add_command(label="Copy", command=partial(self._applyManipulation, CopyImage()))
# manual_menu.add_command(label="Greyscale", command=partial(self._applyManipulation, Grayscale()))
# manual_menu.add_command(label="HSV", command=partial(self._applyManipulation, HSV()))
# manual_menu.add_command(label="Hue Shifted", command=partial(self._applyManipulation, HueShift(), {"hue": 50}))
# manual_menu.add_command(label="Smoothed", command=partial(self._applyManipulation, BoxBlur(), {"ksize": 15}))
# manual_menu.add_command(label="Rotated", command=partial(self._applyManipulation, RotateImage(), {"angle": 90}))
# manual_menu.add_command(label="Flip (Horizontal)", command=partial(self._applyManipulation, FlipImage(), {"mode": "horizontal"}))
# manual_menu.add_command(label="Flip (Vertical)", command=partial(self._applyManipulation, FlipImage(), {"mode": "vertical"}))
# manual_menu.add_command(label="Color Adjust", command=partial(self._applyManipulation, ColorAdjust(), {"brightness": 10, "contrast": 1.2, "saturation": 1.1}))
# manual_menu.add_command(label="Gaussian Blur", command=partial(self._applyManipulation, GaussianBlur(), {"ksize": 5}))
# manual_menu.add_command(label="Sobel Edge", command=partial(self._applyManipulation, SobelEdge(), {"dx": 1, "dy": 0, "ksize": 3}))
# manual_menu.add_command(label="Binary Threshold", command=partial(self._applyManipulation, BinaryThreshold(), {"thresh": 127}))
# manual_menu.add_command(label="Histogram Threshold", command=partial(self._applyManipulation, HistogramThreshold()))
# Frame to hold image

View File

@@ -28,7 +28,7 @@ class ImageContainer:
# PIL Image.size returns (width, height)
return self._imageData.size if self._imageData is not None else (0, 0)
def getImage(self) -> Image:
def getImage(self) -> Image or None:
return self._imageData
def saveImage(self, path: str) -> None:

View File

@@ -19,10 +19,8 @@ class CropImage(ImageManipulation):
image: The image to manipulate
parameters: Parameters for the manipulation (e.g., crop coordinates)
"""
if image is None or getattr(image, "_imageData", None) is None:
return
pil_image = image._imageData
pil_image = image.getImage()
# If parameters provided as dict with width/height, do centered crop
if isinstance(parameters, dict) and "width" in parameters and "height" in parameters:

View File

@@ -7,13 +7,14 @@ class ImageManipulation(ABC):
"""Abstract base class for image manipulation operations."""
@abstractmethod
def manipulateImage(self, image: ImageContainer, parameters: Any) -> None:
def manipulateImage(self, image: ImageContainer, parameters: Any) -> ImageContainer:
"""
Manipulate the given image using the provided parameters.
Args:
image: The image to manipulate
parameters: Parameters for the manipulation
Returns: The manipulated image
"""
pass

3
src/icon.png Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6eed3c9619d01b38005e4aec35623f40dffd930d15764fe54552ffb0f77c38a5
size 1331