Skip to content

Commit

Permalink
11
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoProfe666 committed Jan 10, 2024
1 parent 868c3ed commit b21e634
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
39 changes: 18 additions & 21 deletions src/gui/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tkinter import messagebox

import customtkinter as ctk
from PIL import Image, ImageTk, ImageOps, ImageEnhance, ImageFilter
from PIL import Image, ImageTk, ImageOps, ImageEnhance, ImageFilter, ImageChops

from src.settings import *
from src.gui.components.close_output import CloseOutput
Expand Down Expand Up @@ -100,31 +100,16 @@ def manipulate_image(self, *args):
if self.color_vars['vibrance'].get() != VIBRANCE_DEFAULT:
self.image = ImageEnhance.Color(self.image).enhance(self.color_vars['vibrance'].get())

# grayscale & invert & sepia
if self.color_vars['grayscale'].get():
self.image = ImageOps.grayscale(self.image)

if self.color_vars['invert'].get():
self.image = ImageOps.invert(self.image)

if self.color_vars['sepia'].get():
palette = []
r, g, b = (255, 240, 192)
for i in range(255):
palette.extend((r * i // 255, g * i // 255, b * i // 255))
self.image = self.image.convert('L')
self.image.putpalette(palette)

# blur & contrast & claridad
if self.effect_vars['blur'] != BLUR_DEFAULT:
if self.effect_vars['blur'].get() != BLUR_DEFAULT:
self.image = self.image.filter(ImageFilter.GaussianBlur(self.effect_vars['blur'].get()))
if self.effect_vars['contrast'] != CONTRAST_DEFAULT:
if self.effect_vars['contrast'].get() != CONTRAST_DEFAULT:
self.image = self.image.filter(ImageFilter.UnsharpMask(self.effect_vars['contrast'].get()))
if self.effect_vars['clarity'] != CLARITY_DEFAULT:
if self.effect_vars['clarity'].get() != CLARITY_DEFAULT:
self.image = ImageEnhance.Sharpness(self.image).enhance(self.effect_vars['clarity'].get())

# effects
if self.effect_vars['effect'] != EFFECT_OPTIONS[0]:
if self.effect_vars['effect'].get() != EFFECT_OPTIONS[0]:
match self.effect_vars['effect'].get():
case 'Emboss':
self.image = self.image.filter(ImageFilter.EMBOSS)
Expand All @@ -147,7 +132,19 @@ def manipulate_image(self, *args):
case 'Suave+':
self.image = self.image.filter(ImageFilter.SMOOTH_MORE)

# filters
# grayscale & invert & sepia
if self.color_vars['invert'].get():
self.image = ImageChops.invert(self.image)
if self.color_vars['sepia'].get():
palette = []
r, g, b = (255, 240, 192)
for i in range(255):
palette.extend((r * i // 255, g * i // 255, b * i // 255))
self.image = self.image.convert('L')
self.image.putpalette(palette)
if self.color_vars['grayscale'].get():
self.image = ImageOps.grayscale(self.image)


self.place_image()

Expand Down
12 changes: 6 additions & 6 deletions src/settings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# default values
ROTATE_DEFAULT = 0
ZOOM_DEFAULT = 0
ROTATE_DEFAULT = 0.0
ZOOM_DEFAULT = 0.0
FLIP_OPTIONS = ['Ninguno', 'X', 'Y', 'Ambos']
BLUR_DEFAULT = 0
CONTRAST_DEFAULT = 1
BLUR_DEFAULT = 0.0
CONTRAST_DEFAULT = 1.0
EFFECT_OPTIONS = ['Ningún Efecto', 'Emboss', 'Bordes Find', 'Contour', 'Bordes Enhance', 'Bordes Enhance+', 'Blur', 'Detalles', 'Nítido', 'Suave', 'Suave+']
BRIGHTNESS_DEFAULT = 1
VIBRANCE_DEFAULT = 1
VIBRANCE_DEFAULT = 1.0
GRAYSCALE_DEFAULT = False
SEPIA_DEFAULT = False
INVERT_DEFAULT = False
CLARITY_DEFAULT = 1
CLARITY_DEFAULT = 1.0

# Colors
BACKGROUND_COLOR = '#242424'
Expand Down

0 comments on commit b21e634

Please sign in to comment.