pip install imgkit
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import imgkit html_string = """ <!DOCTYPE html> <html> <head><title>Test</title></head> <body> <h1>Hello, wkhtmltoimage!</h1> <p>This is a sample HTML to image conversion.</p> </body> </html> """ # Convert HTML string to image imgkit.from_string(html_string, 'output_image.jpg') print("Image created successfully.") |