@@ -135,7 +135,7 @@ <h1>Offline Image Converter</h1>
135135
136136 // TODO output type should match media type
137137 function downloadImage ( imageData , fileName , outputType ) {
138- const blob = new Blob ( [ pdf ] , { type : outputType } ) ;
138+ const blob = new Blob ( [ imageData ] , { type : outputType } ) ;
139139 const url = URL . createObjectURL ( blob ) ;
140140 const a = document . createElement ( 'a' ) ;
141141 a . href = url ;
@@ -173,7 +173,7 @@ <h1>Offline Image Converter</h1>
173173 }
174174
175175 if ( type === "done" ) {
176- downloadPdf ( imageData , fileName , outputType ) ;
176+ downloadImage ( imageData , fileName , outputType ) ;
177177 } else if ( type === "error" ) {
178178 showError ( message ) ;
179179 }
@@ -206,9 +206,11 @@ <h1>Offline Image Converter</h1>
206206 // TODO remove dot from filename if present
207207 const fileName = file . name ;
208208 const inputType = "png" ;
209- const imageData = await file . arrayBuffer ( ) ;
210-
211- worker . postMessage ( { imageData, fileName, inputType, outputType } ) ;
209+ const imageDataBuffer = await file . arrayBuffer ( ) ;
210+ const imageData = new Uint8Array ( imageDataBuffer ) ;
211+ const imageTransfer = imageData . buffer ;
212+
213+ worker . postMessage ( { imageData, fileName, inputType, outputType } , [ imageTransfer ] ) ;
212214 }
213215 window . convert = convert ;
214216
0 commit comments