question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't rezie any pngs

See original GitHub issue

png’s dont resize. jpgs work just fine.

This bit of code sends the resized images to S3 for context

function writeObject(data, width, newFilePath, callback) {
    return Sharp(data.Body)
      .resize(width)
      .toFormat('png')
      .toBuffer()
      .then(buffer => S3.putObject({
          Body: buffer,
          Bucket: BUCKET,
          ContentType: 'image/png',
          Key: newFilePath,
        }).promise()
      )
      .then(() => callback(null, {
        statusCode: '301',
        headers: {'location': `${URL}/${newFilePath}`},
        body: '',
      })
    )
}

The output is the original file in original size. I have tried 5 or 6 png files, both from google images and ones I made. I don’t think its a png file issue but I’m happy to link a test image here if needed. I’m also confused why its not throwing an error?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LMS007commented, Dec 19, 2017

@lovell I have not, but I need to get this this soon, probably after the new year. Thanks for following up

0reactions
LMS007commented, Feb 8, 2018

@lovell sorry it took so longer to circle back to this, too many projects not enough time. I went and broke down the code into simple tests and uhm… it was working. Turns out the lambda method I wrote had a bug, not in the writeObject method, but in the wrapper method that recursively called it with various “approved” file extension types that it would restrict on and guess at while grabbing objects from S3. I was only passing the width param the very first time, but not the recursive case and so JPEG was the first extension in my array, PNG was not… e.g. PNG never got the width param… my fault. Long story short, this is not a bug, please close 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot resize png image once placed in photoshop 2021
I can't resize images placed in a photoshop file. The transform/move tool won't let me drag the corners to resize images.
Read more >
PNG not resizing automatically - WordPress.org
I have realised that the feature “Resize my original images” (at the bottom of the first tab) is not resizing PNG images for...
Read more >
Resize PNG Online - Resizing.app
Resize PNG images in Windows 10 · Go to Paint and open your file from the drop-down menu. · Click the Resize tool...
Read more >
PNG resize = large file sizes · Issue #1399 · lovell/sharp - GitHub
My PNG resizes are substantially larger via Sharp, compared to Intervention, which is using Imagemagick under the hood. I've tried all the PNG...
Read more >
Can't resize image using CSS - Stack Overflow
If your image is smaller than the screen, it will use the image width. If it is bigger, it uses max-width. So assuming...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found