Skip to content

Commit 121028a

Browse files
author
Simon he
committed
chore: update
1 parent 3e52f52 commit 121028a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/toBase64.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export function fileToBase64(file: File | Blob) {
2323

2424
export function urlToBase64(url: string) {
2525
return new Promise((resolve, reject) => {
26-
const canvas: HTMLCanvasElement = document.createElement('canvas')
27-
const ctx = canvas.getContext('2d')
28-
const img = new Image()
29-
img.crossOrigin = 'Anonymous'
30-
img.src = `${url}?timeStamp=${new Date().getTime()}`
3126
try {
27+
const canvas: HTMLCanvasElement = document.createElement('canvas')
28+
const ctx = canvas.getContext('2d')
29+
const img = new Image()
30+
img.crossOrigin = 'Anonymous'
31+
img.src = `${url}?timeStamp=${new Date().getTime()}`
3232
img.onload = function () {
3333
ctx?.drawImage(img, 0, 0, canvas.width = img.width, canvas.height = img.height)
3434
resolve(canvas.toDataURL())

0 commit comments

Comments
 (0)