-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculate size automaticly #91
Comments
From the readme:
|
One way is to save it too-big, and then find the bbox for nonzero content with save_dir = os.path.dirname(png_path)
save_name = os.path.basename(png_path)
hti = html2image.Html2Image(output_path=save_dir, size=(2000, 10000))
hti.screenshot(html_str=html, save_as=save_name)
# open the PNG again, and crop it to the content.
from PIL import Image
img = Image.open(png_path)
# Get the content bounds.
content = img.getbbox()
# Crop the image.
img = img.crop(content)
# Save the image.
img.save(png_path) This might only work with very simple web pages, however, like the output of data structure visualizers (in my case, |
Add a function that calculate the size of image automaticly.
The text was updated successfully, but these errors were encountered: