Skip to content
A simple demo that the browser can compress and resize the image using WebAssembly.
HTML JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
mozjpeg
resize
README.md
index.html

README.md

  • A simple demo that the browser can compress and resize the image. Copy some code from the squoosh project, the mozjpeg used to compressing and the Lanczos3 used for resizing.
  • demo is here.
  • You can integrate the code to your project, there's a function which input and output are both File object.
// Get the File object of the original image.
function userUploadImage(file) {
    // The second parameter is the maximum image width.
    // If the input image's width exceeds it, a resizing process will be performed,
    // and the output image's width will be the parameter.
    compressAndResizeImage(file, 1024).then(function (outputFile) {
        // have fun with the compressed and resized image
        fun(outputFile);
    })
}
You can’t perform that action at this time.