import changeImageSize from './changeImageSize' ; export interface IFileProps { file : File ; quality ? : number ; fileType : string ; maxWidth ? : number | string ; maxHeight ? : number | string ; } param file param quality param fileType param maxWidth param maxHeight param callback export default function createThumbnail ( { file , quality , fileType , maxWidth , maxHeight , } ) { return new Promise < string > ( ( resolve ) => { const img = document . createElement ( 'img' ) ; window . URL = window . URL || window . webkitURL ; img . onload = ( ) => { let imgUrl ; if ( quality || maxWidth || maxHeight ) { imgUrl = changeImageSize ( img , quality , fileType ) ; } else { imgUrl = img . src ; } resolve ( imgUrl || '' ) ; } ; img . src = window . URL . createObjectURL ( file ) ; } ) ; }