16 days ago
We are currently working on a NestJS backend API that handles file uploads for insurance proposal documents. The goal is to automatically extract text content from PDF and image files using Google Cloud Vision.
To achieve this, we are:
Accepting PDF or image uploads from the frontend
If a PDF is uploaded, we convert it to PNG using the
pdf2pic
libraryOnce converted to an image, we send it to Google Cloud Vision for OCR processing
The extracted text is saved as part of a new
InsuranceProposal
entity
This solution works perfectly in development and locally on our machines.
Problem on Railway deployment
[Upload] Verificando tipo de arquivo...
[Upload] É um PDF. Iniciando conversão...
[Upload] Erro ao converter PDF para imagem: Error: Could not execute GraphicsMagick/ImageMagick: gm "convert" "-density" "300x300" "-quality" "75" "-[0]" "-resize" "768x512!" "-compress" "jpeg" "/app/uploads/temp/page-ba24e955-312b-4bbe-83de-a96f7f71d9bb.1.png" this most likely means the gm/convert binaries can't be found
at ChildProcess.<anonymous> (/app/node_modules/gm/lib/command.js:249:12)
at ChildProcess.emit (node:events:518:28)
at ChildProcess._handle.onexit (node:internal/child_process:291:12)
does not have the native system binaries required for PDF to image conversion with pdf2pic.
0 Replies