sliders work !
This commit is contained in:
1 parent
e962e4bfa6
commit
1b6c4c00f9
1 file changed
+38
-24
+38
-24
@@ -5,7 +5,6 @@
|
||||
# 0000.jpg = peut-être page vide ?
|
||||
# 000n.jpg = peut-être page vide ?
|
||||
|
||||
#
|
||||
# Faire ces premières modifications, puis on passe aux ajustements luminosité,
|
||||
# contraste, etc
|
||||
#
|
||||
@@ -20,9 +19,8 @@ from os import listdir
|
||||
import os
|
||||
import glob
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from tkinter import ttk, filedialog
|
||||
from PIL import Image, ImageTk, ImageEnhance
|
||||
from tkinter import filedialog
|
||||
|
||||
parent = tk.Tk()
|
||||
parent.title("Perlinator")
|
||||
@@ -95,23 +93,33 @@ for path in paths:
|
||||
bulk_optimize(path, path.stem, 1.0, 0.5, 0.5)
|
||||
# TEST LOGIC END
|
||||
|
||||
b_slider_double = tk.DoubleVar()
|
||||
c_slider_double = tk.DoubleVar()
|
||||
s_slider_double = tk.DoubleVar()
|
||||
|
||||
# Python program to demonstrate
|
||||
# scale widget
|
||||
from tkinter import *
|
||||
|
||||
b_slider_double = DoubleVar()
|
||||
c_slider_double = DoubleVar()
|
||||
s_slider_double = DoubleVar()
|
||||
original_pil_image = Image.open("./test/tux.jpg")
|
||||
img = ImageTk.PhotoImage(original_pil_image)
|
||||
panel = tk.Label(parent, image=img)
|
||||
panel.pack()
|
||||
|
||||
|
||||
def get_sliders():
|
||||
|
||||
print(
|
||||
b_slider_double.get() / 100,
|
||||
c_slider_double.get() / 100,
|
||||
s_slider_double.get() / 100,
|
||||
)
|
||||
pil_img = original_pil_image.copy()
|
||||
|
||||
brightness = ImageEnhance.Brightness(pil_img)
|
||||
pil_img = brightness.enhance(b_slider_double.get() / 100)
|
||||
|
||||
contrast = ImageEnhance.Contrast(pil_img)
|
||||
pil_img = contrast.enhance(c_slider_double.get() / 100)
|
||||
|
||||
sharpness = ImageEnhance.Sharpness(pil_img)
|
||||
pil_img = sharpness.enhance(s_slider_double.get() / 100)
|
||||
|
||||
img = ImageTk.PhotoImage(pil_img)
|
||||
panel.configure(image=img)
|
||||
panel.image = img # Keep a reference to prevent gc
|
||||
|
||||
return (
|
||||
b_slider_double.get() / 100,
|
||||
c_slider_double.get() / 100,
|
||||
@@ -122,24 +130,30 @@ def get_sliders():
|
||||
b_slider_val, c_slider_val, s_slider_val = get_sliders()
|
||||
|
||||
# 1 to 100 → 0 to 1
|
||||
b_slider = Scale(parent, variable=b_slider_double, from_=0, to=100, orient=HORIZONTAL)
|
||||
c_slider = Scale(parent, variable=c_slider_double, from_=0, to=100, orient=HORIZONTAL)
|
||||
s_slider = Scale(parent, variable=s_slider_double, from_=0, to=100, orient=HORIZONTAL)
|
||||
b_slider = tk.Scale(
|
||||
parent, variable=b_slider_double, from_=0, to=200, orient=tk.HORIZONTAL
|
||||
)
|
||||
c_slider = tk.Scale(
|
||||
parent, variable=c_slider_double, from_=0, to=200, orient=tk.HORIZONTAL
|
||||
)
|
||||
s_slider = tk.Scale(
|
||||
parent, variable=s_slider_double, from_=0, to=200, orient=tk.HORIZONTAL
|
||||
)
|
||||
|
||||
show_enhance_button = Button(
|
||||
show_enhance_button = tk.Button(
|
||||
parent,
|
||||
text="Preview",
|
||||
command=get_sliders,
|
||||
bg="yellow",
|
||||
)
|
||||
|
||||
l1 = Label(parent)
|
||||
l1 = tk.Label(parent)
|
||||
|
||||
b_slider.pack(anchor=CENTER)
|
||||
c_slider.pack(anchor=CENTER)
|
||||
s_slider.pack(anchor=CENTER)
|
||||
b_slider.pack(anchor=tk.CENTER)
|
||||
c_slider.pack(anchor=tk.CENTER)
|
||||
s_slider.pack(anchor=tk.CENTER)
|
||||
|
||||
show_enhance_button.pack(anchor=CENTER)
|
||||
show_enhance_button.pack(anchor=tk.CENTER)
|
||||
l1.pack()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user