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

Can't rezie any pngs #1040

Closed
LMS007 opened this issue Nov 23, 2017 · 5 comments
Closed

Can't rezie any pngs #1040

LMS007 opened this issue Nov 23, 2017 · 5 comments
Labels

Comments

@LMS007
Copy link

LMS007 commented Nov 23, 2017

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?

@lovell
Copy link
Owner

lovell commented Nov 23, 2017

Hello, please can you provide a reduced test case that removes all the S3/HTTP logic and focuses only on sharp.

@LMS007
Copy link
Author

LMS007 commented Nov 25, 2017

Roger that, I'll output directly to local disk and post again. Thanks Lovell, the package is great otherwise!

@lovell
Copy link
Owner

lovell commented Dec 19, 2017

@LMS007 Were you able to make any progress with this?

@LMS007
Copy link
Author

LMS007 commented Dec 19, 2017

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

@LMS007
Copy link
Author

LMS007 commented 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 :)

@lovell lovell closed this as completed Feb 8, 2018
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