遇到一個網站使用的驗證碼是 svg 格式, 背景是透明的, 會讓 ddddocr 產生錯誤.
解法是要把 svg 轉成 png 格式之後的透明圖層置換成白色背景:
https://stackoverflow.com/questions/3008538/removing-html-canvas-alpha-channel
context.fillStyle = "rgb(0, 0, 0)"; // without alpha
context.fillRect(0, 0, your_canvas_width, your_canvas_height);
相關文章
How To Convert An SVG To An Image In The Browser?
https://stackoverflow.max-everyday.com/2023/03/how-to-convert-an-svg-to-an-image-in-the-browser/