param image param mimeType param quality export default function compressImage ( image , mimeType , quality = 1 ) { return new Promise ( ( resolve ) => { const canvas = document . createElement ( 'canvas' ) ; canvas . width = image . width ; canvas . height = image . height ; const ctx = canvas . getContext ( '2d' ) ; if ( ctx ) { ctx . drawImage ( image , 0 , 0 ) ; canvas . toBlob ( resolve , mimeType , quality ) ; } else { resolve ( null ) ; } } ) ; }