From d3b8eb3036e84c69f16925ec601a473a309940f6 Mon Sep 17 00:00:00 2001 From: 230419 <230419@epvc.pt> Date: Fri, 1 May 2026 22:47:49 +0100 Subject: [PATCH] add by files --- src/App.jsx | 68 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index a4dfe7f..2ac121b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -707,6 +707,44 @@ export default function App() { reader.readAsDataURL(file); }; + const handleItemImageUpload = (e) => { + const file = e.target.files[0]; + if (!file) return; + + const reader = new FileReader(); + reader.onload = (event) => { + const img = new Image(); + img.onload = () => { + const canvas = document.createElement('canvas'); + const MAX_SIZE = 800; // Tamanho maior para roupas + let width = img.width; + let height = img.height; + + if (width > height) { + if (width > MAX_SIZE) { + height *= MAX_SIZE / width; + width = MAX_SIZE; + } + } else { + if (height > MAX_SIZE) { + width *= MAX_SIZE / height; + height = MAX_SIZE; + } + } + + canvas.width = width; + canvas.height = height; + const ctx = canvas.getContext('2d'); + ctx.drawImage(img, 0, 0, width, height); + const base64Data = canvas.toDataURL('image/jpeg', 0.8); + + setImageUrlDraft(base64Data); + }; + img.src = event.target.result; + }; + reader.readAsDataURL(file); + }; + const saveProfile = async (e) => { e.preventDefault(); setSavingProfile(true); @@ -1011,7 +1049,7 @@ export default function App() {
Selecione pelo menos uma cor
}