add pictures inbox resize to thumb and sort
This commit is contained in:
parent
3efa55919f
commit
1e7a81acd2
@ -1,4 +0,0 @@
|
||||
<html><head><title>Dragonfeu land</title></head><body> # Dragonfeu land - Articles
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
<h1>Navigation</h1><br><a href=/index.html>index.html</a><h1>Articles en Français</h1><br><a href=/lang_fr//2024-11-02-coucou-gemini.html>2024-11-02-coucou-gemini.html</a><br><a href=/2024/coucou-gemini>2024 coucou gemini</a><br><a href=/lang_fr//2024-09-08-strategie-mitigation-accident-fusion-coeur-epr2.html>2024-09-08-strategie-mitigation-accident-fusion-coeur-epr2.html</a><br><a href=/2024/strategie-mitigation-accident-fusion-coeur-epr2>2024 strategie mitigation accident fusion coeur epr2</a><br><a href=/lang_fr//2024-05-15-l-aventure-superphenix.html>2024-05-15-l-aventure-superphenix.html</a><br><a href=/2024/l-aventure-superphenix>2024 l aventure superphenix</a><br><a href=/lang_fr//2023-06-10-recap-centrale-zaporijia.html>2023-06-10-recap-centrale-zaporijia.html</a><br><a href=/2023/recap-centrale-zaporijia>2023 recap centrale zaporijia</a><br><a href=/lang_fr//2023-06-09-recapitulatif-contenu-threads.html>2023-06-09-recapitulatif-contenu-threads.html</a><br><a href=/2023/recapitulatif-contenu-threads>2023 recapitulatif contenu threads</a></article></body></html>
|
BIN
pictures_inbox/20241109_221755.jpg
Normal file
BIN
pictures_inbox/20241109_221755.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 MiB |
BIN
pictures_inbox/20241109_221813.jpg
Normal file
BIN
pictures_inbox/20241109_221813.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 MiB |
BIN
pictures_inbox/20241114_150147.jpg
Normal file
BIN
pictures_inbox/20241114_150147.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 MiB |
BIN
pictures_inbox/20241114_150727.jpg
Normal file
BIN
pictures_inbox/20241114_150727.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 MiB |
51
pictures_resize.py
Normal file
51
pictures_resize.py
Normal file
@ -0,0 +1,51 @@
|
||||
# on redimensionne nos images qui ullustreront les articles,
|
||||
# pour cela on les copie dans notre dossier pictures_inbox.
|
||||
# elles sont copiées en version réduite, et déplacées dans le dossier de l'année
|
||||
# ce script génère aussi de quoi copier des liens org affichant les thumbnails de l'image liée à la grande version
|
||||
|
||||
import os
|
||||
from PIL import Image
|
||||
from datetime import datetime
|
||||
|
||||
# Variables
|
||||
INPUT_DIR = "pictures_inbox"
|
||||
OUTPUT_DIR = "output/pictures"
|
||||
YEAR = datetime.now().strftime("%Y")
|
||||
SMALL_SUFFIX = "_small"
|
||||
IMAGE_FORMAT = "jpg"
|
||||
|
||||
# Créer le dossier de sortie s'il n'existe pas
|
||||
os.makedirs(os.path.join(OUTPUT_DIR, YEAR), exist_ok=True)
|
||||
|
||||
# Parcourir toutes les images dans le dossier d'entrée
|
||||
for filename in os.listdir(INPUT_DIR):
|
||||
# Vérifier si c'est bien un fichier
|
||||
if os.path.isfile(os.path.join(INPUT_DIR, filename)):
|
||||
# Récupérer le nom de base de l'image et son extension
|
||||
base_name = os.path.splitext(filename)
|
||||
extension = os.path.splitext(filename)[1].lower()
|
||||
|
||||
# Créer le nom pour la version réduite
|
||||
small_image_name = f"{base_name[0]}{SMALL_SUFFIX}.{IMAGE_FORMAT}"
|
||||
|
||||
# Chemins des images
|
||||
input_image_path = os.path.join(INPUT_DIR, filename)
|
||||
small_image_path = os.path.join(OUTPUT_DIR, YEAR, small_image_name)
|
||||
original_image_path = os.path.join(OUTPUT_DIR, YEAR, filename)
|
||||
|
||||
# Redimensionner l'image
|
||||
with Image.open(input_image_path) as img:
|
||||
img = img.resize((600, int(img.height * 600 / img.width)), Image.Resampling.LANCZOS)
|
||||
img.save(small_image_path, 'JPEG') # Utiliser 'JPEG' au lieu de 'JPG'
|
||||
|
||||
# Copier l'image originale dans le dossier de sortie
|
||||
with open(input_image_path, 'rb') as f:
|
||||
with open(original_image_path, 'wb') as f_out:
|
||||
f_out.write(f.read())
|
||||
|
||||
# Écrire la ligne pour le document .org
|
||||
org_line = f"[[file:wp-uploads/content/i/{YEAR}/{small_image_name}][{filename}]]\n"
|
||||
with open(os.path.join("output", f"images_{YEAR}.org"), "a") as org_file:
|
||||
org_file.write(org_line)
|
||||
|
||||
print("Traitement terminé.")
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user