Skip to content

Build your personal knowledge base with Trilium Notes

fix(ocr): automatic OCR not respecting language

Elian Doran605fbaaa4a54
diff --git a/apps/server/src/services/image.ts b/apps/server/src/services/image.ts
index e94fae2e7e..3e25584d5c 100644
--- a/apps/server/src/services/image.ts
+++ b/apps/server/src/services/image.ts
@@ -33,25 +33,7 @@ async function processImage(uploadBuffer: Buffer, originalName: string, shrinkIm
// Process OCR asynchronously without blocking image creation
setImmediate(async () => {
try {
- const ocrResult = await ocrService.extractTextFromFile(uploadBuffer, imageMime);
- if (ocrResult) {
- // We need to get the entity again to get its blobId after it's been saved
- // noteId could be either a note ID or attachment ID
- const note = becca.getNote(noteId);
- const attachment = becca.getAttachment(noteId);
-
- let blobId: string | undefined;
- if (note && note.blobId) {
- blobId = note.blobId;
- } else if (attachment && attachment.blobId) {
- blobId = attachment.blobId;
- }
-
- if (blobId) {
- await ocrService.storeOCRResult(blobId, ocrResult);
- log.info(`Successfully processed OCR for image ${noteId} (${originalName})`);
- }
- }
+ await ocrService.processNoteOCR(noteId);
} catch (error) {
log.error(`Failed to process OCR for image ${noteId}: ${error}`);
}
diff --git a/apps/server/src/services/ocr/ocr_service.ts b/apps/server/src/services/ocr/ocr_service.ts
index f4d0fc1e68..0e7488e737 100644
--- a/apps/server/src/services/ocr/ocr_service.ts
+++ b/apps/server/src/services/ocr/ocr_service.ts
@@ -137,7 +137,7 @@ class OCRService {
*/
async extractTextFromFile(fileBuffer: Buffer, mimeType: string, options: OCRProcessingOptions = {}): Promise<OCRResult> {
try {
- log.info(`Starting OCR text extraction for MIME type: ${mimeType} with language: ${options.language || "auto-detect"}`);
+ log.info(`Starting OCR text extraction for MIME type: ${mimeType} with language: ${options.language || "eng"}`);
this.isProcessing = true;
// Find appropriate processor