top | item 37648630

(no title)

avivo | 2 years ago

If you can provide a script that takes in an HTML file and provides an image ready for rendering, that would be amazing. Then I can automatically take any website and have a cron job that dumps the result into a shared dropbox link where it can be used by the screen.

discuss

order

konschubert|2 years ago

> If you can provide a script that takes in an HTML file and provides an image ready for rendering, that would be amazing.

Yea, that's something I have been trying to build, but it's surprisingly non-trivial. There are a bunch of headless browser options, but I haven't found a good way to tell them: "Render the page in X width and Y height and then take a screenshot".

That seems like a problem that should have 100 open source solutions for it, and I am sure there are some that work really well! But I personally haven't found one yet.

ticoombs|2 years ago

> "Render the page in X width and Y height and then take a screenshot".

Isn't this the exact example of phantomjs?

``` page.viewportSize = { width: 600, height: 600 }; ```

At least that is what I use to do for screen testing for some of our low-hanging-fruit QA. At some point I rewrote it in puppeteer and it was as simple as the above line.

The screenshot results in being the X/Y size.

I'd be interested in why this doesn't work in your usecase.

simonbw|2 years ago

I made something almost exactly like this before. I needed to convert svgs to pngs and have them display the same way they looked in the browser. It turned out that spinning up chromium and taking a screenshot was the easiest thing way to do that. I think I used puppeteer.

Headless Chrome seems like it should be able to do what you want pretty easily. https://developer.chrome.com/blog/headless-chrome/

IanCal|2 years ago

It feels fairly reasonable imo to specify something like "this uses phantomjs with the following screen size" and just say peoples work has to fit that.