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

Image is blurry after resizing puppeteer screenshot #4066

Closed
neilgandhi95 opened this issue Apr 16, 2024 · 2 comments
Closed

Image is blurry after resizing puppeteer screenshot #4066

neilgandhi95 opened this issue Apr 16, 2024 · 2 comments
Labels

Comments

@neilgandhi95
Copy link

neilgandhi95 commented Apr 16, 2024

Question about an existing feature

I'm trying to resize a screenshot taken with Puppeteer, and finding the image to be very blurry

When you searched for similar issues, what did you find that might be related?

I looked through a few threads here and the docs and tried messing with the kernel, but with no success

Please provide a minimal, standalone code sample, wit

const screenshotBuffer = await page.screenshot({ path: "screenshot.png" }); //puppeteer screenshot
const resizedBuffer = await sharp(screenshotBuffer)
        .resize(365, 206, {
          fit: "fill",
          kernel: "lanczos3",
          fastShrinkOnLoad: false,
        })
        .toBuffer();

Please provide sample image(s) that help explain this question

Without resize:
image

With resize:
image

With resize, zoomed in to show blurry
image

That same image resized in Figma is perfect quality
image 2 (2)

@lovell
Copy link
Owner

lovell commented Apr 16, 2024

kernel: "lanczos3",

It looks like you've already found the kernel parameter. You'll need to experiment with the other possible values to see which provides the best output for your scenario.

https://sharp.pixelplumbing.com/api-resize#resize

@lovell
Copy link
Owner

lovell commented Apr 29, 2024

I hope this information helped. Please feel free to re-open with more details if further assistance is required.

@lovell lovell closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants