vgalin / html2image

A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.
MIT License
354 stars 43 forks source link

Fixing temporary folder management and snap validation in Linux #119

Closed jjpaulo2 closed 7 months ago

jjpaulo2 commented 1 year ago

I made two things here:

I did this two comments, recently:

About the permissions

When I used the library at first time, I got a blank image. But after override the temp_path parameter of Html2Image, it worked perfectly to me.

Then, at a first momment, trying to fix it, I replaced manual creation of the temporary folders, with ready-to-use, Python's tempfile.TemporaryFolder interface. But this didn't have fixed the problem. The blank image was still there.

About the snap validation

I am using Chrome from snap. After I found the code validating the snap installation, and came to do some tests, using the absolute path declared in the code, the generation of the image got worked fine.

Conclusion

Now, using the combination of the tempfile module and validating the snap installation first, the most of problems with blank images must be solved.