Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(ui): preserve avatar transparency when WebP is supported

Timothy Yin99def80b1a4a
diff --git a/apps/cloud/app/components/CloudAccountProfile.vue b/apps/cloud/app/components/CloudAccountProfile.vue
index 916ca184..8990af93 100644
--- a/apps/cloud/app/components/CloudAccountProfile.vue
+++ b/apps/cloud/app/components/CloudAccountProfile.vue
@@ -30,8 +30,6 @@ async function chooseImage(event: Event) {
canvas.width = canvas.height = 128
const size = Math.min(bitmap.width, bitmap.height)
const drawing = canvas.getContext('2d')!
- drawing.fillStyle = '#ffffff'
- drawing.fillRect(0, 0, 128, 128)
drawing.drawImage(
bitmap,
(bitmap.width - size) / 2,
@@ -44,8 +42,12 @@ async function chooseImage(event: Event) {
128,
)
let result = canvas.toDataURL('image/webp', 0.85)
- if (!result.startsWith('data:image/webp;'))
+ if (!result.startsWith('data:image/webp;')) {
+ drawing.globalCompositeOperation = 'destination-over'
+ drawing.fillStyle = '#ffffff'
+ drawing.fillRect(0, 0, 128, 128)
result = canvas.toDataURL('image/jpeg', 0.85)
+ }
if (result.length > 65536) throw new Error('Image too large')
image.value = result
} finally {