zmniejszenie jakosci wgrywanych zjec

This commit is contained in:
Mateusz Gruszczyński
2025-08-18 10:18:40 +02:00
parent f9ffd083af
commit 899bb6eb3a

10
app.py
View File

@@ -142,9 +142,9 @@ TIME_WINDOW = 60 * 60
WEBP_SAVE_PARAMS = {
"format": "WEBP",
"lossless": True, # lub False jeśli chcesz używać quality
"lossless": False, # False jeśli chcesz używać quality
"method": 6,
# "quality": 95, # tylko jeśli lossless=False
"quality": 95, # tylko jeśli lossless=False
}
db = SQLAlchemy(app)
@@ -500,7 +500,7 @@ def save_resized_image(file, path):
pass
try:
image.thumbnail((2000, 2000))
image.thumbnail((1500, 1500))
image = image.convert("RGB")
image.info.clear()
@@ -965,9 +965,9 @@ def save_pdf_as_webp(file, path):
combined.paste(img, (0, y_offset))
y_offset += img.height
combined.thumbnail((2000, 20000))
new_path = path.rsplit(".", 1)[0] + ".webp"
combined.save(new_path, **WEBP_SAVE_PARAMS)
#combined.save(new_path, **WEBP_SAVE_PARAMS)
combined.save(new_path, format="WEBP")
except Exception as e:
raise ValueError(f"Błąd podczas przetwarzania PDF: {e}")