perf: optimize image processing
This commit is contained in:
parent
7681682445
commit
9438a3169d
1 changed files with 7 additions and 1 deletions
|
@ -250,7 +250,13 @@ const Footer: FC = () => {
|
|||
const handleInjectImage = async (file: File) => {
|
||||
try {
|
||||
setInputLoading(true)
|
||||
const blob = await compressImage({ input: file, targetSize: 30 * 1024, outputType: 'image/webp' })
|
||||
|
||||
const blob = await compressImage({
|
||||
input: file,
|
||||
targetSize: 30 * 1024,
|
||||
outputType: file.size > 30 * 1024 ? 'image/webp' : undefined
|
||||
})
|
||||
|
||||
const base64 = await blobToBase64(blob)
|
||||
const hash = nanoid()
|
||||
const newMessage = `${message.slice(0, selectionEnd)}![Image](hash:${hash})${message.slice(selectionEnd)}`
|
||||
|
|
Loading…
Reference in a new issue