QUploader for images, how to compress images ?



  • I try to compress selected images with a Image Compressor.

    So, using ‘filter’ property of QUploader, for each file, i use new ImageCompressor(file), -> return compressed file.
    but how much do I use
    The problem, ImageCompressor is a async function, need use ‘async’ and ‘await’ to wait callback from ImageCompressor, but how much i use ‘async’ in function called by ‘filter’ property, the following errors are occurred:

    Example function
    async qUploaderFilter(files) {
    // ImageCompressor logic

    return files;
    },

    ERROR:

    Uncaught TypeError: e.map is not a function
    at VueComponent.__add (quasar.mat.esm.js?e083:6)
    at invoker (vue.runtime.esm.js?2b0e:2023)
    at HTMLInputElement.fn._withTask.fn._withTask (vue.runtime.esm.js?2b0e:1822)


    so, exist another solution for image compression before upload?