diff --git a/app/app.py b/app/app.py index e2d8467..cb0401c 100644 --- a/app/app.py +++ b/app/app.py @@ -686,9 +686,11 @@ def check_resize(): try: sizes = [int(s) for s in raw_sizes if int(s) in RESIZE_SIZES] except (ValueError, TypeError): - return jsonify({"conflicts": []}) + sizes = [] formats = [f for f in raw_formats if f in RESIZE_FORMATS] + + src_ext = target.suffix.lstrip(".") stem = re.sub(r"_\d+x\d+$", "", target.stem) parent = target.parent @@ -701,6 +703,19 @@ def check_resize(): except (ValueError, TypeError): pass + # Pas de dimensions sélectionnées → conserver celles d'origine + if not all_dims: + try: + src = Image.open(target) + all_dims = [(src.width, src.height)] + src.close() + except Exception: + return jsonify({"conflicts": []}) + + # Pas de format sélectionné → conserver le format d'origine + if not formats: + formats = [src_ext] + conflicts = [] for fmt in formats: for w, h in all_dims: @@ -764,8 +779,14 @@ def resize_image(): pass all_dims = square_dims + custom_dims - if not all_dims or not formats: - return jsonify({"error": "Aucune dimension ou format valide"}), 400 + + # Pas de dimensions sélectionnées → conserver celles d'origine + if not all_dims: + all_dims = [(max_w, max_h)] + + # Pas de format sélectionné → conserver le format d'origine + if not formats: + formats = [ext.lstrip(".")] conflict = request.form.get("conflict", "skip") if conflict not in ("backup", "overwrite", "rename", "skip"): @@ -842,6 +863,9 @@ def resize_image(): else: img = Image.open(target) + # LANCZOS ne supporte pas le mode palette (ICO, GIF…) + if img.mode not in ("RGB", "RGBA", "L", "LA", "I", "F"): + img = img.convert("RGBA") img = img.resize((w, h), Image.LANCZOS) if fmt == "png": if img.mode not in ("RGBA", "RGB", "L"): diff --git a/app/templates/preview_image.html b/app/templates/preview_image.html index 919ba87..63282da 100644 --- a/app/templates/preview_image.html +++ b/app/templates/preview_image.html @@ -143,7 +143,7 @@ {% endif %}
Erreur réseau.
'; } result.style.display = 'block'; - btn.textContent = 'Générer les copies'; - btn.disabled = !canSubmit(); + btn.textContent = btnLabel(); + btn.disabled = false; resizeResolved = false; }