Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text #5

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Web to Kindle

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/kreativitat/web-to-kindle-heroku)

2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Web to Kindle",
"description": "A service to create Kindle-ready web page screenshots",
"repository": "https://github.com/lankybutmacho/web-to-kindle-heroku",
"repository": "https://github.com/kreativitat/web-to-kindle-heroku",
"buildpacks": [
{
"url": "heroku/nodejs"
Expand Down
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ express()
.get('/', async (req, res) => {
const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
const page = await browser.newPage();
await page.setViewport({ width: 600, height: 800 });
await page.setViewport({ width: 1072, height: 1448 });
await page.goto(process.env.SCREENSHOT_URL || 'https://darksky.net/details/40.7127,-74.0059/2021-1-6/us12/en');
// wait 5 sec
await page.waitFor(5000);
//await page.waitForNavigation({ waitUntil: 'networkidle0' });

await page.screenshot({
path: '/tmp/screenshot.png',
});
Expand All @@ -35,7 +39,7 @@ express()

function convert(filename) {
return new Promise((resolve, reject) => {
const args = [filename, '-gravity', 'center', '-extent', '600x800', '-colorspace', 'gray', '-depth', '8', filename];
const args = [filename, '-gravity', 'center', '-extent', '1072x1448', '-colorspace', 'gray', '-depth', '8', filename];
execFile('convert', args, (error, stdout, stderr) => {
if (error) {
console.error({ error, stdout, stderr });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/lankybutmacho/web-to-kindle-heroku"
"url": "https://github.com/kreativitat/web-to-kindle-heroku"
},
"license": "MIT"
}