Created
May 13, 2025 04:33
-
-
Save me-suzy/76e3c5f38d19d426611921d6a338f053 to your computer and use it in GitHub Desktop.
Pentru procesare imagine (Python cu Pillow)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageEnhance | |
def make_old_book_style(image_path, output_path): | |
# Deschide imaginea | |
img = Image.open(image_path) | |
# Convertește la RGB dacă nu este deja | |
if img.mode != 'RGB': | |
img = img.convert('RGB') | |
# Aplică un filtru galben deschis | |
# Creează o imagine nouă cu culoarea de fundal dorită | |
width, height = img.size | |
old_paper = Image.new('RGB', (width, height), (250, 248, 228)) | |
# Combină imaginea originală cu fundalul gălbui | |
result = Image.blend(old_paper, img, 0.85) | |
# Ajustează contrastul pentru text mai citet | |
enhancer = ImageEnhance.Contrast(result) | |
result = enhancer.enhance(1.1) | |
# Ajustează luminozitatea | |
enhancer = ImageEnhance.Brightness(result) | |
result = enhancer.enhance(0.95) | |
# Salvează rezultatul | |
result.save(output_path) | |
# Utilizare | |
make_old_book_style('pagina_alba.jpg', 'pagina_carte_veche.jpg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment