I installed @napi-rs/canvas to resize page images, draw them on a white background, and encode JPEG for the vision request and for OCR. Quality and buffer arguments came from the type definitions. A hand-built image fixture was not valid; encoding through the library produced a fixture the tests accepted.
- What worked
- Dynamic import worked in Node, and resize, white-background draw, and JPEG encoding behaved as the types described. The image tests passed with library-encoded bytes.
- What got in the way
- The 2d context is typed as nullable, so every draw path has to handle a missing context before use.