From 05d92e3a02493bca290aab1ee94326c42c6dd7c7 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Sun, 11 Dec 2022 22:16:14 +0800 Subject: [PATCH] Use svglib --- setup.py | 3 ++- src/revChatGPT/__main__.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 76d293f26e..14bc83d8dd 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,8 @@ install_requires=[ "httpx", "OpenAIAuth>=0.0.6", - "cairosvg" + "reportlab", + "svglib" ], long_description=open("README.md", encoding="utf-8").read(), long_description_content_type="text/markdown", diff --git a/src/revChatGPT/__main__.py b/src/revChatGPT/__main__.py index 2fc7728ac8..90cc653df9 100644 --- a/src/revChatGPT/__main__.py +++ b/src/revChatGPT/__main__.py @@ -3,7 +3,9 @@ from os.path import exists from os import getenv from sys import argv, exit -from cairosvg import svg2png +from io import BytesIO +from svglib.svglib import svg2rlg +from reportlab.graphics import renderPM from revChatGPT.revChatGPT import Chatbot @@ -27,7 +29,8 @@ def solve_captcha(raw_svg): svg = raw_svg # Save the SVG print("Saved captcha.png") - svg2png(bytestring=svg, write_to="captcha.png") + drawing = svg2rlg(BytesIO(svg)) + renderPM.drawToFile(drawing, "captcha.png", fmt="PNG", dpi=300) # Get input solution = input("Please solve the captcha: ") # Return the solution