html2image icon indicating copy to clipboard operation
html2image copied to clipboard

Getting blank png from HTML

Open tilusnet opened this issue 2 years ago • 4 comments

I tried from command line and from Python as well, I always get a blank PNG file.

Example:

$ hti -v -H kaya.al.html -S op.png -s 1024,768 -o ~/tmp/hti

args = Namespace(browser=None, chrome_path=None, css=[], html=['kaya.al.html'], other=[], output_path='<home>/tmp/hti', quiet=False, save_as=['op.png'], size=[(1024, 768)], temp_path=None, url=[], verbose=True)
[0217/100850.406393:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
[0217/100850.417779:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[0217/100850.565404:INFO:headless_shell.cc(659)] Written to file <home>/tmp/hti/op.png.
Created 1 file(s):
	<home>/tmp/hti/op.png

tilusnet avatar Feb 17 '22 10:02 tilusnet

Hello, could you take a look at the issue #47 and try out some of the solutions I suggested?

vgalin avatar Feb 17 '22 11:02 vgalin

Hi.

I just saw #47 and tried using an absolute path to the HTML, but it doesn't make any difference.

tilusnet avatar Feb 17 '22 11:02 tilusnet

My bad, #47 is not related to this issue. I thought you reffered to <img> tags appearing as blank in your screenshots, but it seems that you are getting completely blank screenshots, right?

This may be related to #46 instead : if you installed chromium via snap it may not have access to the temporary directory that html2image uses to store files.

Could you check your Chromium version to see if it mentions snap? If that's the case, using the --temp_path flag with a directory located under your home directory could make up a temporary fix.

If your Chromium version does not mention snap, I'll probably need some additionnal information such as :

  • Your browser type/version
  • Your OS and its version
  • And potentially a minimal HTML file with which it is possible to reproduce the issue

vgalin avatar Feb 17 '22 11:02 vgalin

Hi @vgalin

Yes, my chromium is a snap installation.

You are correct, specifying --temp_path under my home fixes it:

hti -v -H kaya.al.html -S op.png -s 1024,768 -o ~/tmp/hti --temp_path=~/tmp

In addition to my confusion around what browser it is actually being picked up, I wrote #58. I also have chrome installed on my system (which is being managed by my employer), so it is important to get the transparency around the browser in use.

Thanks for your prompt help.

tilusnet avatar Feb 17 '22 11:02 tilusnet