diff --git a/frontend/src/components/FileUploadZone.vue b/frontend/src/components/FileUploadZone.vue
index b9dbc60..a3d9387 100644
--- a/frontend/src/components/FileUploadZone.vue
+++ b/frontend/src/components/FileUploadZone.vue
@@ -21,6 +21,15 @@ defineProps({
isDragOver: { type: Boolean, default: false },
isProcessing: { type: Boolean, required: true },
phaseText: { type: String, required: true },
+ // Billing/usage note aside - this is about EXTRACTION QUALITY, a
+ // real reported case: a low-resolution photo/screenshot upload can
+ // read so poorly via OCR that the result needs careful manual review
+ // even after the backend's own upscaling correction (see CLAUDE.md's
+ // "Two real bugs found investigating a specific real-world statement
+ // report" entry). {[name:size]: {width, height}}, keyed the same way
+ // chosenFiles' own dedup already is - see useFileUpload.js's own
+ // lowResolutionWarnings docstring.
+ lowResolutionWarnings: { type: Object, default: () => ({}) },
})
const emit = defineEmits(['file-input-change', 'drag-over', 'drag-leave', 'drop', 'remove-file', 'extract'])
@@ -53,10 +62,29 @@ const extractionStore = useExtractionStore()
pulled back out before Extract is ever clicked. -->
- {{ f.name }}
-
+
+ {{ f.name }}
+
+
+
+
+
+ Low resolution ({{ lowResolutionWarnings[f.name + ':' + f.size].width }}×{{ lowResolutionWarnings[f.name + ':' + f.size].height }}px) -
+ the app will try to correct for this, but text recognition may still suffer and the result may need manual
+ review/correction. Consider a clearer or higher-resolution photo instead, or continue if you accept the risk.
+
diff --git a/frontend/src/composables/useFileUpload.js b/frontend/src/composables/useFileUpload.js
index a2d0dc5..3cd0406 100644
--- a/frontend/src/composables/useFileUpload.js
+++ b/frontend/src/composables/useFileUpload.js
@@ -11,12 +11,56 @@ import { ref } from 'vue'
import { useExtractionStore } from '../stores/extractionStore'
const ACCEPTED_FILE_RE = /\.(pdf|jpe?g|png)$/i
+const IMAGE_FILE_RE = /\.(jpe?g|png)$/i
+// Mirrors the backend's own raw_ocr_extract._MIN_OCR_WIDTH_PX exactly -
+// that's the width below which the backend already upscales before OCR
+// (see CLAUDE.md's "Two real bugs found investigating a specific real-
+// world statement report" entry) - this is the matching FRONTEND-side
+// warning threshold, surfaced at upload time rather than only
+// discovered after a Preview/extraction comes back wrong. A PDF isn't
+// checked at all - a scanned PDF page is rendered server-side at a
+// fixed resolution regardless of whatever the original scan's own
+// resolution was, so there's nothing meaningful to read client-side
+// for it the way a bare image's own naturalWidth directly is one.
+const LOW_RESOLUTION_WIDTH_PX = 1600
+
+/**
+ * The real natural pixel width of an image file, or null if it
+ * couldn't be read (never rejects - a failed probe just means no
+ * warning is shown, not that the file is blocked).
+ */
+function probeImageWidth(file) {
+ return new Promise((resolve) => {
+ const url = URL.createObjectURL(file)
+ const img = new Image()
+ img.onload = () => {
+ resolve({ width: img.naturalWidth, height: img.naturalHeight })
+ URL.revokeObjectURL(url)
+ }
+ img.onerror = () => {
+ resolve(null)
+ URL.revokeObjectURL(url)
+ }
+ img.src = url
+ })
+}
export function useFileUpload() {
const extractionStore = useExtractionStore()
const chosenFiles = ref([])
const isDragOver = ref(false)
+ /**
+ * {["name:size"]: {width, height}} for every staged image found to be
+ * below LOW_RESOLUTION_WIDTH_PX - keyed the same way chosenFiles'
+ * own dedup already is, so FileUploadZone.vue can look a warning up
+ * for a given staged file with no extra bookkeeping. Populated
+ * asynchronously (probing an image's real dimensions takes a load),
+ * so a file can briefly show with no warning before one appears a
+ * moment later - an honest reflection of when the check actually
+ * resolves, not worth blocking the staged-file display on.
+ */
+ const lowResolutionWarnings = ref({})
/**
* Validates and ADDS files to whatever's already staged for the next
@@ -47,18 +91,36 @@ export function useFileUpload() {
if (!staged.has(key)) {
chosenFiles.value.push(f)
staged.add(key)
+ // Fire-and-forget - never awaited here, so staging itself stays
+ // synchronous and instant; the warning (if any) just appears a
+ // moment later once the probe resolves. Only a bare image is
+ // checked at all (see LOW_RESOLUTION_WIDTH_PX's own comment for
+ // why a PDF is skipped).
+ if (IMAGE_FILE_RE.test(f.name)) {
+ probeImageWidth(f).then((dims) => {
+ if (dims && dims.width < LOW_RESOLUTION_WIDTH_PX) {
+ lowResolutionWarnings.value = { ...lowResolutionWarnings.value, [key]: dims }
+ }
+ })
+ }
}
}
}
/** Removes one staged file (by its position in chosenFiles) before it's ever uploaded. */
function removeChosenFile(index) {
+ const f = chosenFiles.value[index]
chosenFiles.value.splice(index, 1)
+ if (f) {
+ const { [f.name + ':' + f.size]: _removed, ...rest } = lowResolutionWarnings.value
+ lowResolutionWarnings.value = rest
+ }
}
/** Empties the staging list - called once a batch has been handed off to extraction, so those files aren't left sitting there to be accidentally re-extracted (and duplicated) by a later click. */
function clearChosenFiles() {
chosenFiles.value = []
+ lowResolutionWarnings.value = {}
}
function onFileInputChange(e) {
@@ -85,7 +147,7 @@ export function useFileUpload() {
}
return {
- chosenFiles, isDragOver,
+ chosenFiles, isDragOver, lowResolutionWarnings,
setFiles, removeChosenFile, clearChosenFiles, onFileInputChange, onDragOver, onDragLeave, onDrop,
}
}