image enhancements basic logic
This commit is contained in:
1 parent
e7d74c85ec
commit
17fb5437c9
1 file changed
+34
-3
+34
-3
@@ -11,15 +11,17 @@
|
|||||||
#
|
#
|
||||||
# Puis on fait le PDF puis on OCR.
|
# Puis on fait le PDF puis on OCR.
|
||||||
|
|
||||||
|
# class PIL.ImageTk.PhotoImage(image: Image.Image | str | None = None, size: tuple[int, int] | None = None, **kw: Any)
|
||||||
|
|
||||||
# list_of_num = [int(i.split(".")[0]) for i in a]
|
# list_of_num = [int(i.split(".")[0]) for i in a]
|
||||||
# list_of_num.sort()
|
# list_of_num.sort()
|
||||||
|
|
||||||
|
from os import listdir
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk, ImageEnhance
|
||||||
import os
|
|
||||||
from os import listdir
|
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
|
|
||||||
parent = tk.Tk()
|
parent = tk.Tk()
|
||||||
@@ -65,6 +67,35 @@ def upload_folder():
|
|||||||
popup.after(2000, popup.destroy)
|
popup.after(2000, popup.destroy)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# test logic, not real
|
||||||
|
files = []
|
||||||
|
|
||||||
|
|
||||||
|
def bulk_optimize(
|
||||||
|
source_path: str, dest_path: str, b: float, c: float, s: float
|
||||||
|
) -> None:
|
||||||
|
with Image.open(source_path) as img:
|
||||||
|
brightness = ImageEnhance.Brightness(img)
|
||||||
|
contrast = ImageEnhance.Contrast(img)
|
||||||
|
sharpness = ImageEnhance.Sharpness(img)
|
||||||
|
|
||||||
|
brightness.enhance(b)
|
||||||
|
contrast.enhance(c)
|
||||||
|
sharpness.enhance(s)
|
||||||
|
|
||||||
|
files.append(img)
|
||||||
|
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
paths = Path(".").glob("*.png")
|
||||||
|
for path in paths:
|
||||||
|
bulk_optimize(path, path.stem, 1.0, 0.5, 0.5)
|
||||||
|
# TEST LOGIC END
|
||||||
|
|
||||||
|
|
||||||
# def order_pages():
|
# def order_pages():
|
||||||
# global image_files
|
# global image_files
|
||||||
# image_files.sort(key=lambda x: int(x.split(".")[0]))
|
# image_files.sort(key=lambda x: int(x.split(".")[0]))
|
||||||
|
|||||||
Reference in new issue
Block a user