Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,12 +10,12 @@ from streamlit_cropper import st_cropper
|
|
| 10 |
# --- PAGE CONFIG ---
|
| 11 |
st.set_page_config(page_title="Smart Doc Scanner", page_icon="🖼️", layout="centered")
|
| 12 |
|
| 13 |
-
# --- Resize Function ---
|
| 14 |
-
def resize_image(img,
|
| 15 |
-
if img.
|
| 16 |
-
ratio =
|
| 17 |
-
|
| 18 |
-
img = img.resize((
|
| 19 |
return img
|
| 20 |
|
| 21 |
# --- HEADER ---
|
|
@@ -62,7 +62,6 @@ if uploaded_files:
|
|
| 62 |
|
| 63 |
col_cropper, col_preview = st.columns([1, 1])
|
| 64 |
|
| 65 |
-
# --- Hugging Face-safe cropper ---
|
| 66 |
with col_cropper:
|
| 67 |
st.markdown("### ✂️ Select Crop Area (Original Image):")
|
| 68 |
crop_output = st_cropper(
|
|
|
|
| 10 |
# --- PAGE CONFIG ---
|
| 11 |
st.set_page_config(page_title="Smart Doc Scanner", page_icon="🖼️", layout="centered")
|
| 12 |
|
| 13 |
+
# --- Resize Function (Height Based) ---
|
| 14 |
+
def resize_image(img, max_height=500):
|
| 15 |
+
if img.height > max_height:
|
| 16 |
+
ratio = max_height / img.height
|
| 17 |
+
new_width = int(img.width * ratio)
|
| 18 |
+
img = img.resize((new_width, max_height), resample=Image.Resampling.LANCZOS)
|
| 19 |
return img
|
| 20 |
|
| 21 |
# --- HEADER ---
|
|
|
|
| 62 |
|
| 63 |
col_cropper, col_preview = st.columns([1, 1])
|
| 64 |
|
|
|
|
| 65 |
with col_cropper:
|
| 66 |
st.markdown("### ✂️ Select Crop Area (Original Image):")
|
| 67 |
crop_output = st_cropper(
|