MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / compress

Function compress

frontend/packages/common/src/utils/uploadPic.ts:25–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23 const ctx = canvas.getContext('2d')
24
25 const compress = () => {
26 canvas.width = width
27 canvas.height = height
28 ctx?.clearRect(0, 0, width, height)
29 ctx?.drawImage(img, 0, 0, width, height)
30
31 const dataUrl = canvas.toDataURL(file.type, quality)
32 const base64 = dataUrl.split(',')[1]
33 return { base64, size: base64.length * 0.75 }
34 }
35
36 let { base64, size } = compress()
37

Callers 1

compressImageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected