File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,24 @@ export function drawImageInCanvas(img) {
177
177
return canvas ;
178
178
}
179
179
180
+ /**
181
+ * Detect IOS device
182
+ * see: https://stackoverflow.com/a/9039885
183
+ * @returns {boolean } isIOS device
184
+ */
185
+ function isIOS ( ) {
186
+ return [
187
+ 'iPad Simulator' ,
188
+ 'iPhone Simulator' ,
189
+ 'iPod Simulator' ,
190
+ 'iPad' ,
191
+ 'iPhone' ,
192
+ 'iPod' ,
193
+ ] . includes ( navigator . platform )
194
+ // iPad on iOS 13 detection
195
+ || ( navigator . userAgent . includes ( 'Mac' ) && 'ontouchend' in document ) ;
196
+ }
197
+
180
198
/**
181
199
* drawFileInCanvas
182
200
*
@@ -186,6 +204,9 @@ export function drawImageInCanvas(img) {
186
204
export async function drawFileInCanvas ( file ) {
187
205
let img ;
188
206
try {
207
+ if ( isIOS ( ) ) {
208
+ throw new Error ( 'Skip createImageBitmap on IOS device' ) ; // see https://github.com/Donaldcwl/browser-image-compression/issues/118
209
+ }
189
210
img = await createImageBitmap ( file ) ;
190
211
} catch ( e ) {
191
212
const dataUrl = await getDataUrlFromFile ( file ) ;
You can’t perform that action at this time.
0 commit comments