humanmade / tachyon

Faster than light image resizing service that runs on AWS. Super simple to set up, highly available and very performant.

Home Page:https://engineering.hmn.md/projects/tachyon/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Large PNG image error

gblakeman opened this issue · comments

It seems like a large image (PNG file > 2000x2000 px) is causing an error: {"message": "Internal server error"}.

I’ve tried increasing the Lambda memory allocation but it hasn’t worked. Any other ideas how I might troubleshoot the issue?

It seems that the chosen node sharp version can’t transform high-res pngs properly, leading to blown up file sizes which lambda refuse to serve (check for “body size too long” in cloud watch). The limit is 6MB if I remember correctly. Ended up modifying the lambda handler to use imagemin-pngquant when dealing with pngs.

@tedyw Ha, that make sense. I’d noticed the biggest PNG I could generate was just under 6mb. Thanks for the tip!

@tedyw do you have a fork we could look at? Sounds like something it'd be good to fix.

I'm hoping to get sharp updated soon as well but there's a breaking change related to webp that's blocking us right now.

Updated sharp but still seeing PNGs getting inflated size wise. Trying to understand why but looks like the imagemin solution might be necessary after all

This can often happen whenever a PNG is resampled. Essentially, whenever you resize a PNG, there is antialiasing that occurs, which introduced new colors to the image and increases the overall size.

See https://core.trac.wordpress.org/ticket/30402#comment:4 for more conversation about this problem.

This is the description of why Sharp produces large PNG files: lovell/sharp#478 I think we should add pngquant or the wrapper imagemin (so we can handle other compressions in the future). https://github.com/imagemin/imagemin looks like a good option, though depends on the install size, as we are getting close to the 50MB zip file limit.

This is in v2.2.0-beta2