Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


> 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.


> "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.


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/


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.


Hi! A while ago I had exactly the same problem and thought process, so I made this: https://github.com/SmilyOrg/website-image-proxy

Hopefully you find it useful :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: