foone / SierraDeathGenerator

Generate fake screenshots from video games
https://deathgenerator.com
GNU General Public License v3.0
615 stars 61 forks source link

feature request: API to allow programmatic creation #35

Open Fuzzwah opened 4 years ago

Fuzzwah commented 4 years ago

I'd like to rig up my slackbot to allow users to create versions of these images via triggers. Any chance of making an API available?

TheLastZombie commented 4 years ago

See http://floppy.foone.org/w/Death_Generator:

Two commonly asked questions are "Does the death generator have an API?" and "Can I easily run it from the command line?" and the answer to both questions is no. Both are on the to-do list but can't really be done with the current design.

The main obstacle is that it's HTML canvas based and explicitly tied to the HTML page it works with. At some point I'll split it out and use some kind of canvas wrapper to let you run it from the command line as a node.js app, but not that hasn't been done yet.

If you really really need to generate from the command line, you can. Not easily or quickly, but you can with a bit of work: Look into evaluate_test_cases.js. This is a node.js script that takes in a JSON file and then runs some headless Chromium instances against it, returning the output images (at 1:1 scaling instead of the default 2:1, you may want to disable this depending on your needs) encoded into JSON. test.py contains some example code for extracting the images from the response JSON.

skhaz commented 4 years ago

I did a telegram bot[0] using puppeteer and other tools.

0 - https://github.com/skhaz/telegram-sierradeathgenerator