20260629222128

This commit is contained in:
oneao committed 2026-06-29 22:21:28 +08:00
1 parent 6ab4ae9c77
commit 96299ba9a2
20 files changed
+614 -409

No files matched your search

+117
View File
@@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
import sys
import io
import urllib.request
from PIL import Image
URL = ("http://118.89.70.199:9001/test/finance-category-default/income/hongbao.webp"
"?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD"
"&X-Amz-Credential=54WPUR104SA9X00EKWS3%2F20260629%2Fus-east-1%2Fs3%2Faws4_request"
"&X-Amz-Date=20260629T105003Z&X-Amz-Expires=86400"
"&X-Amz-Security-Token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3ODI3NzMyMDUsInBhcmVudCI6Im9uZWFvIn0.zkP6L1zg_LPy1UuK-3-VT6LEWuhLNickKWTWDly_PzJCnwIRPS4naSZE9Lx84HtXPVVhxaZguHXl65AXjROJZA"
"&X-Amz-Signature=b763181ad8bf74deb2ac55ac18402d26a91075088c9c109cfd3a4da6cca7b38f"
"&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject")
out_path = r"D:\workspace\code\app\.workbuddy\hongbao.webp"
req = urllib.request.Request(URL, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req, timeout=60) as resp:
data = resp.read()
print("Downloaded bytes:", len(data))
with open(out_path, "wb") as f:
f.write(data)
img = Image.open(out_path)
print("Format:", img.format)
print("Size:", img.size)
print("Mode:", img.mode)
# Force load pixel data
img.load()
has_alpha = img.mode in ("RGBA", "LA") or (img.mode == "P" and "transparency" in img.info)
print("Has alpha channel:", has_alpha)
if img.mode == "P":
# Convert palette to RGBA to inspect real pixels
rgba = img.convert("RGBA")
elif img.mode != "RGBA":
rgba = img.convert("RGBA")
else:
rgba = img
w, h = rgba.size
px = rgba.load()
def info(x, y):
r, g, b, a = px[x, y]
return f"({x},{y}) RGBA=({r},{g},{b},{a})"
print("\n--- Corner pixels ---")
print("TL", info(0, 0))
print("TR", info(w - 1, 0))
print("BL", info(0, h - 1))
print("BR", info(w - 1, h - 1))
print("\n--- Edge midpoints ---")
print("Top-mid", info(w // 2, 0))
print("Bottom-mid", info(w // 2, h - 1))
print("Left-mid", info(0, h // 2))
print("Right-mid", info(w - 1, h // 2))
# Statistics over all pixels
total = w * h
transparent = 0 # alpha == 0
near_transparent = 0 # alpha < 255 and > 0
fully_opaque = 0 # alpha == 255
white_pixels = 0 # opaque & RGB ~ (255,255,255)
near_white_bg = 0 # alpha==0 OR rgb near white
for y in range(h):
for x in range(w):
r, g, b, a = px[x, y]
if a == 0:
transparent += 1
elif a < 255:
near_transparent += 1
else:
fully_opaque += 1
if r > 245 and g > 245 and b > 245:
white_pixels += 1
print("\n--- Global statistics ---")
print("Total pixels:", total)
print("Fully transparent (a==0):", transparent, f"({100*transparent/total:.2f}%)")
print("Semi-transparent (0<a<255):", near_transparent, f"({100*near_transparent/total:.2f}%)")
print("Fully opaque (a==255):", fully_opaque, f"({100*fully_opaque/total:.2f}%)")
print("Opaque & near-white:", white_pixels, f"({100*white_pixels/total:.2f}%)")
# Border-only statistics (outer 2px ring) - this is what reveals background
def is_border(x, y, w, h, t=2):
return x < t or y < t or x >= w - t or y >= h - t
border_total = 0
border_trans = 0
border_white = 0
for y in range(h):
for x in range(w):
if is_border(x, y, w, h):
border_total += 1
r, g, b, a = px[x, y]
if a == 0:
border_trans += 1
elif r > 245 and g > 245 and b > 245:
border_white += 1
print("\n--- Border ring (outer 2px) ---")
print("Border pixels:", border_total)
print("Border transparent:", border_trans, f"({100*border_trans/border_total:.2f}%)")
print("Border near-white opaque:", border_white, f"({100*border_white/border_total:.2f}%)")
print("\n=== CONCLUSION ===")
if border_trans / border_total > 0.5:
print("BACKGROUND IS TRANSPARENT (alpha channel, mostly a==0 at edges)")
elif border_white / border_total > 0.5:
print("BACKGROUND IS WHITE (opaque near-white pixels at edges)")
else:
print("Background is neither clearly transparent nor white - inspect manually")
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

+47
View File
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw
src = r"D:\workspace\code\app\.workbuddy\hongbao.webp"
img = Image.open(src).convert("RGBA")
w, h = img.size
tile = 16
# Panel 1: checkerboard background (shows transparency)
def make_checker(width, height, t):
cb = Image.new("RGB", (width, height), (255, 255, 255))
d = ImageDraw.Draw(cb)
for y in range(0, height, t):
for x in range(0, width, t):
if (x // t + y // t) % 2 == 0:
d.rectangle([x, y, x + t - 1, y + t - 1], fill=(204, 204, 204))
return cb
checker = make_checker(w, h, tile).convert("RGBA")
panel1 = Image.alpha_composite(checker, img).convert("RGB")
# Panel 2: white background
white_bg = Image.new("RGBA", (w, h), (255, 255, 255, 255))
panel2 = Image.alpha_composite(white_bg, img).convert("RGB")
# Panel 3: alpha channel as grayscale (white = opaque, black = transparent)
alpha = img.split()[3]
panel3 = Image.merge("RGB", (alpha, alpha, alpha))
# Combine with labels
gap = 10
label_h = 28
total_w = w * 3 + gap * 2
total_h = h + label_h
canvas = Image.new("RGB", (total_w, total_h), (245, 245, 245))
canvas.paste(panel1, (0, label_h))
canvas.paste(panel2, (w + gap, label_h))
canvas.paste(panel3, (w * 2 + gap * 2, label_h))
d = ImageDraw.Draw(canvas)
d.text((4, 6), "Transparent bg (checker)", fill=(0, 0, 0))
d.text((w + gap + 4, 6), "White bg", fill=(0, 0, 0))
d.text((w * 2 + gap * 2 + 4, 6), "Alpha channel", fill=(0, 0, 0))
out = r"D:\workspace\code\app\.workbuddy\hongbao_bg_compare.png"
canvas.save(out)
print("Saved:", out)
+22
View File
@@ -0,0 +1,22 @@
# 2026-06-29 工作日志
## finance_default 图标背景色检查
- 检查 `finance-category-default/income/hongbao.webp` 背景是否透明
- 使用 Python + Pillow 下载并分析像素 alpha 通道
- 结果:**背景为透明色**(RGBA 模式,外层 2px 边缘 100% 完全透明 a==0,全局 38.15% 像素完全透明)
- 图片尺寸 256x256,webp 格式
- 生成对比图 `hongbao_bg_compare.png`(透明棋盘格 / 白色背景 / alpha 通道三视图)
- 分析脚本:`.workbuddy/check_bg.py`、`.workbuddy/make_compare.py`
## finance/add/index.tsx 修复
- 修复第 302 行乱码:`璁拌处` → `记账`(UTF-8 被误解释为 GBK)
## FinanceCategoryIcon 背景色修复
- 移除 `FinanceCategoryIcon` 内部 View 的 `backgroundColor: "#F3F4F6"`(DEFAULT_BG)
- 根因:该背景色遮挡了外层选中态 `bg-accent` 绿色,导致图片透明区域显示灰色而非绿色
- 选中态背景由外层 `CategoryItem` 的 `bg-accent` / `bg-gray-100` 控制
## 记账 add 页面 BottomSheet 布局调整
- 分类 icon+名称与日期合并到同一行(左右分布)
- 金额移除 Label,居中放大(text-4xl)
- 备注保持不变