top | item 21246726 JavaScript Image Compress Using HTML5 Canvas and File API Before Upload 32 points| huzoorbux | 6 years ago |phplift.net 13 comments order hn newest [+] [-] Piskvorrr|6 years ago|reply Database hugged to death :(Oh wait. It's a redirect to StackOverflow?!https://stackoverflow.com/questions/23945494/use-html5-to-re... [+] [-] throwaway_bad|6 years ago|reply 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...) load replies (1) [+] [-] huzoorbux|6 years ago|reply I have used JIC JavaScript Library to perform this task.https://raw.githubusercontent.com/brunobar79/J-I-C/master/sr... [+] [-] accosine|6 years ago|reply This can be done in like five lines of Javascript. Why does this even rank on HN? [+] [-] tmikaeld|6 years ago|reply 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 [+] [-] untog|6 years ago|reply What's the minimum number of lines before code becomes notable enough for HN? load replies (1) [+] [-] devwastaken|6 years ago|reply browsers need to have an API to access the underlying libraries. No reason I shouldn't be able to use turbojpeg or libpng clientside. Can't even do it in WebAssembly, because simd was an afterthought. [+] [-] mcraiha|6 years ago|reply There should be a law that says: "one shall not use var in JavaScript code examples" [+] [-] yoz-y|6 years ago|reply Don't linters complain about it nowadays? Maybe devtools should start doing it too.
[+] [-] Piskvorrr|6 years ago|reply Database hugged to death :(Oh wait. It's a redirect to StackOverflow?!https://stackoverflow.com/questions/23945494/use-html5-to-re... [+] [-] throwaway_bad|6 years ago|reply 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...) load replies (1) [+] [-] huzoorbux|6 years ago|reply I have used JIC JavaScript Library to perform this task.https://raw.githubusercontent.com/brunobar79/J-I-C/master/sr...
[+] [-] throwaway_bad|6 years ago|reply 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...) load replies (1)
[+] [-] huzoorbux|6 years ago|reply I have used JIC JavaScript Library to perform this task.https://raw.githubusercontent.com/brunobar79/J-I-C/master/sr...
[+] [-] accosine|6 years ago|reply This can be done in like five lines of Javascript. Why does this even rank on HN? [+] [-] tmikaeld|6 years ago|reply 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 [+] [-] untog|6 years ago|reply What's the minimum number of lines before code becomes notable enough for HN? load replies (1)
[+] [-] tmikaeld|6 years ago|reply 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
[+] [-] untog|6 years ago|reply What's the minimum number of lines before code becomes notable enough for HN? load replies (1)
[+] [-] devwastaken|6 years ago|reply browsers need to have an API to access the underlying libraries. No reason I shouldn't be able to use turbojpeg or libpng clientside. Can't even do it in WebAssembly, because simd was an afterthought.
[+] [-] mcraiha|6 years ago|reply There should be a law that says: "one shall not use var in JavaScript code examples" [+] [-] yoz-y|6 years ago|reply Don't linters complain about it nowadays? Maybe devtools should start doing it too.
[+] [-] yoz-y|6 years ago|reply Don't linters complain about it nowadays? Maybe devtools should start doing it too.
[+] [-] Piskvorrr|6 years ago|reply
Oh wait. It's a redirect to StackOverflow?!
https://stackoverflow.com/questions/23945494/use-html5-to-re...
[+] [-] throwaway_bad|6 years ago|reply
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...)
[+] [-] huzoorbux|6 years ago|reply
https://raw.githubusercontent.com/brunobar79/J-I-C/master/sr...
[+] [-] accosine|6 years ago|reply
[+] [-] tmikaeld|6 years ago|reply
Image-conversion is the library I've used the most, since you can target file-size || quality:
https://github.com/WangYuLue/image-conversion
[+] [-] untog|6 years ago|reply
[+] [-] devwastaken|6 years ago|reply
[+] [-] mcraiha|6 years ago|reply
[+] [-] yoz-y|6 years ago|reply