Skip to content

poc: Generate thumbnail with playwright #494

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

josebui
Copy link
Contributor

@josebui josebui commented May 9, 2023

Description

  • POC to generate a thumbnail using playwright
  • For the production implementation I expect this to go to a lambda or a fargate process that we can call on demand to generate the thumbnails

});
const page = await context.newPage();

await context.addCookies([
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially we could inpersonate a user to get a thumbnail of their private data, it seems that this is not needed for the first iteration

@garobrik garobrik assigned garobrik and unassigned garobrik Jun 13, 2023

fs.writeFile(outputPath, screenshotBuffer, (err) => {
if (err) {
console.error('Error saving screenshot:', err);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.error('Error saving screenshot:', err);
console.error('Error saving screenshot to ${outputPath}:', err);

Comment on lines +38 to +46
// sharp(screenshotBuffer)
// .resize(200, 150) // Set the thumbnail dimensions here
// .toFile(outputPath, (err, info) => {
// if (err) {
// console.error('Error generating thumbnail:', err);
// } else {
// console.log('Thumbnail generated successfully:', info);
// }
// });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what's this for? can it be removed?

},
]);

await page.goto('https://app.staging.terraso.net/tools/story-maps/f2xs943/ecuador-2'); // Replace with the URL of the website you want to capture
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await page.goto('https://app.staging.terraso.net/tools/story-maps/f2xs943/ecuador-2'); // Replace with the URL of the website you want to capture
await page.goto(pageUrl);

const sharp = require('sharp');
const fs = require('fs');
const path = require('path');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const pageUrl = 'https://app.staging.terraso.net/tools/story-maps/f2xs943/ecuador-2'; // Replace with the URL of the website you want to capture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants