fix: complete image pipeline - rotation, URL, preview

- Add rotation_degrees parameter to ImageProcessor.process_photo()
- Pass rotation through _auto_save_photo_from_extraction() to processor
- Allow no-crop fallback when crop_bounds is None
- Add buildPhotoUrl() helper to resolve backend URLs correctly
- Update frontend components to use backend URL for image sources
- Replace Use/Skip Photo buttons with checkbox in AI extraction UI
- Add images/ to .gitignore to prevent accidental commits

Addresses: rotation never applied, image 404s (relative to Next.js not backend), preview blank in edit form
This commit is contained in:
2026-04-22 08:50:25 +03:00
parent 1c13ebd76f
commit 64d177e791
10 changed files with 79 additions and 70 deletions

View File

@@ -2,7 +2,7 @@
import React, { useState, useRef } from 'react';
import { Item } from '@/lib/db';
import { inventoryApi } from '@/lib/api';
import { inventoryApi, buildPhotoUrl } from '@/lib/api';
import ItemPhotoUpload from '@/components/ItemPhotoUpload';
import { X, Camera, Trash2 } from 'lucide-react';
import { toast } from 'react-hot-toast';
@@ -12,6 +12,7 @@ interface ItemDetailModalProps {
onClose: () => void;
onPhotoUpdated?: (photo: { thumbnail_url: string; full_url: string; uploaded_at: string }) => void;
onItemRefresh?: () => void;
backendUrl?: string;
}
export default function ItemDetailModal({
@@ -19,6 +20,7 @@ export default function ItemDetailModal({
onClose,
onPhotoUpdated,
onItemRefresh,
backendUrl = '',
}: ItemDetailModalProps) {
const [showPhotoUpload, setShowPhotoUpload] = useState(false);
const [currentPhoto, setCurrentPhoto] = useState<{ thumbnail_url: string; full_url: string } | null>(
@@ -119,7 +121,7 @@ export default function ItemDetailModal({
<div className="space-y-3">
<div className="relative bg-slate-900/50 rounded-2xl overflow-hidden border border-slate-800/50 aspect-video max-h-96">
<img
src={currentPhoto.full_url}
src={buildPhotoUrl(backendUrl, currentPhoto.full_url)}
alt={item.name}
className="w-full h-full object-contain"
/>