Fix image compression for avis and banner images
This commit is contained in:
parent
7215da135b
commit
29020fbcee
3 changed files with 37 additions and 19 deletions
|
@ -36,8 +36,8 @@ export const PhotoCarouselPicker = ({
|
|||
cropping: true,
|
||||
...IMAGE_PARAMS,
|
||||
})
|
||||
const uri = await compressIfNeeded(cameraRes, 300000)
|
||||
onSelectPhotos([uri, ...selectedPhotos])
|
||||
const img = await compressIfNeeded(cameraRes, 300000)
|
||||
onSelectPhotos([img.path, ...selectedPhotos])
|
||||
} catch (err: any) {
|
||||
// ignore
|
||||
store.log.warn('Error using camera', err)
|
||||
|
@ -52,8 +52,8 @@ export const PhotoCarouselPicker = ({
|
|||
path: uri,
|
||||
...IMAGE_PARAMS,
|
||||
})
|
||||
const finalUri = await compressIfNeeded(cropperRes, 300000)
|
||||
onSelectPhotos([finalUri, ...selectedPhotos])
|
||||
const img = await compressIfNeeded(cropperRes, 300000)
|
||||
onSelectPhotos([img.path, ...selectedPhotos])
|
||||
} catch (err: any) {
|
||||
// ignore
|
||||
store.log.warn('Error selecting photo', err)
|
||||
|
@ -76,8 +76,8 @@ export const PhotoCarouselPicker = ({
|
|||
path: image.path,
|
||||
...IMAGE_PARAMS,
|
||||
})
|
||||
const finalUri = await compressIfNeeded(cropperRes, 300000)
|
||||
result.push(finalUri)
|
||||
const finalImg = await compressIfNeeded(cropperRes, 300000)
|
||||
result.push(finalImg.path)
|
||||
}
|
||||
onSelectPhotos([...result, ...selectedPhotos])
|
||||
})
|
||||
|
|
|
@ -55,18 +55,18 @@ export function Component({
|
|||
}
|
||||
const onSelectNewAvatar = async (img: PickedImage) => {
|
||||
try {
|
||||
setNewUserAvatar(img)
|
||||
const uri = await compressIfNeeded(img, 300000)
|
||||
setUserAvatar(uri)
|
||||
const finalImg = await compressIfNeeded(img, 300000)
|
||||
setNewUserAvatar(finalImg)
|
||||
setUserAvatar(finalImg.path)
|
||||
} catch (e: any) {
|
||||
setError(e.message || e.toString())
|
||||
}
|
||||
}
|
||||
const onSelectNewBanner = async (img: PickedImage) => {
|
||||
try {
|
||||
setNewUserBanner(img)
|
||||
const uri = await compressIfNeeded(img, 500000)
|
||||
setUserBanner(uri)
|
||||
const finalImg = await compressIfNeeded(img, 500000)
|
||||
setNewUserBanner(finalImg)
|
||||
setUserBanner(finalImg.path)
|
||||
} catch (e: any) {
|
||||
setError(e.message || e.toString())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue