fix: modal actually processes image with rotation/crop and fixes zoom
Critical fixes: 1. Modal now applies rotation and crop to image, returns processed blob 2. Frontend sends processed image to backend (not original) 3. Zoom slider min/max now calculated based on image size 4. Initial zoom shows entire image in canvas 5. Zoom constraints prevent over-zooming or under-zooming User experience improved: - Sees full item at start (auto-fit zoom) - Can adjust rotation/crop smoothly - Adjusted image is what gets saved (not original) - Zoom slider works correctly for any image size Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,13 +60,12 @@ export default function AIOnboarding({ onCancel, onComplete, categories, invento
|
||||
setShowImageAdjustment(true);
|
||||
};
|
||||
|
||||
const handleImageAdjustmentConfirm = async (adjustments: { rotation: number; cropBounds: { x: number; y: number; width: number; height: number } } | null) => {
|
||||
const handleImageAdjustmentConfirm = async (adjustments: any) => {
|
||||
if (!pendingItemData) return;
|
||||
|
||||
const { index } = pendingItemData;
|
||||
|
||||
if (adjustments && extractedItems[index]) {
|
||||
// Override AI-detected values with user adjustments
|
||||
const updatedItems = [...extractedItems];
|
||||
updatedItems[index] = {
|
||||
...updatedItems[index],
|
||||
@@ -82,11 +81,27 @@ export default function AIOnboarding({ onCancel, onComplete, categories, invento
|
||||
user_adjusted: true
|
||||
}
|
||||
};
|
||||
setExtractedItems(updatedItems);
|
||||
|
||||
// If modal processed and returned image blob, use that instead of original
|
||||
if (adjustments.imageBlob) {
|
||||
// Convert blob to base64 for extracted_image_bytes
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
const base64 = (reader.result as string).split(',')[1];
|
||||
updatedItems[index].extractedImageBlob = adjustments.imageBlob;
|
||||
updatedItems[index]._base64ImageData = base64;
|
||||
setExtractedItems(updatedItems);
|
||||
hookConfirmSingleItem(index);
|
||||
};
|
||||
reader.readAsDataURL(adjustments.imageBlob);
|
||||
} else {
|
||||
setExtractedItems(updatedItems);
|
||||
hookConfirmSingleItem(index);
|
||||
}
|
||||
} else {
|
||||
hookConfirmSingleItem(index);
|
||||
}
|
||||
|
||||
// Now call the hook's confirm with the updated data
|
||||
hookConfirmSingleItem(index);
|
||||
setShowImageAdjustment(false);
|
||||
setAdjustingItemIndex(null);
|
||||
setPendingItemData(null);
|
||||
|
||||
Reference in New Issue
Block a user