Live data from Hacker News

JavaScript Image Compress Using HTML5 Canvas and File API Before Upload

phplift.net

1–10 of 14 posts

Re: JavaScript Image Compress Using HTML5 Canvas and File API Before Upload

#5
post #4
post #3

This can be done in like five lines of Javascript. Why does this even rank on HN?

What's the minimum number of lines before code becomes notable enough for HN?

7 can be acceptable in some cases, but just to be safe I suggest 8 lines.

// 8 Lines not including sarcastic comments obviously.

Re: JavaScript Image Compress Using HTML5 Canvas and File API Before Upload

#7
post #3

This can be done in like five lines of Javascript. Why does this even rank on HN?

There might not be that many that know about it?

Image-conversion is the library I've used the most, since you can target file-size || quality:

https://github.com/WangYuLue/image-conversion

Re: JavaScript Image Compress Using HTML5 Canvas and File API Before Upload

#8
post #4

Earlier quoted context omitted.

What's the minimum number of lines before code becomes notable enough for HN?

7 can be acceptable in some cases, but just to be safe I suggest 8 lines. // 8 Lines not including sarcastic comments obviously.

These are the new standards, please send out a memo.

Re: JavaScript Image Compress Using HTML5 Canvas and File API Before Upload

#10

Database hugged to death :( Oh wait. It's a redirect to StackOverflow?! https://stackoverflow.com/questions/23945494/use-html5-to-re...

Squoosh is a much better demo of how to do in-browser compression (using optipng, mozjpeg, etc): https://github.com/GoogleChromeLabs/squoosh/

There are far more knobs you can tune whereas the native browser conversion only has mimetype and quality (via toBlob: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasE...)

Post reply on HN