From 2a80c42c87f0cc1b5db8402d14e59dcd165c744a Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 14 Mar 2023 11:56:52 +0800 Subject: [PATCH] Some images have small artifacts of alpha transparency Change requirement to at least 50% transparency. Not perfect, good for now. --- src/components/avatar.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/avatar.jsx b/src/components/avatar.jsx index 7f16980a..c424ac7c 100644 --- a/src/components/avatar.jsx +++ b/src/components/avatar.jsx @@ -57,9 +57,10 @@ function Avatar({ url, size, alt = '', ...props }) { canvas.height, ); const hasAlpha = allPixels.data.some((pixel, i) => { - return i % 4 === 3 && pixel !== 255; + return i % 4 === 3 && pixel <= 128; }); if (hasAlpha) { + console.log('hasAlpha', hasAlpha, allPixels.data); avatarRef.current.classList.add('has-alpha'); alphaCache[url] = true; }