fix: 홈 첫 로드 가볍게 — 쇼츠 유튜브 플레이어를 첫 조작 뒤에 불러오고 첫 표지는 먼저 받음(LCP), 아이콘은 WebP 사본(4.6MB → 0.8MB)·계절 사진 재압축, 쇼츠_미리보기 이벤트 추가
This commit is contained in:
1 parent
6383911fb3
commit
38ae9374fd
174 files changed
+90
-10
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"""아이콘 PNG 옆에 웹용 WebP 사본을 만든다. 아이콘을 추가하거나 바꾼 뒤 실행한다.
|
||||
|
||||
python frontend/scripts/icons_webp.py
|
||||
|
||||
웹은 WebP 를 쓰고(frontend/src/b/lib.ts iconSrc), PNG 원본은 앱·admin 카드가 그대로 쓴다.
|
||||
PNG 보다 새 WebP 가 이미 있으면 건너뛴다. Pillow 가 필요하다 (backend 와 같은 패키지).
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
|
||||
PUBLIC = Path(__file__).resolve().parent.parent / "public"
|
||||
DIRS = [PUBLIC / "icons", PUBLIC / "b" / "icons"]
|
||||
# 아이콘은 256px 정사각형. 그보다 큰 그림(원본·로고)은 아이콘이 아니라 건너뛴다
|
||||
MAX_SIDE = 256
|
||||
QUALITY = 85
|
||||
|
||||
|
||||
def main() -> None:
|
||||
made = 0
|
||||
for folder in DIRS:
|
||||
for png in sorted(folder.glob("*.png")):
|
||||
webp = png.with_suffix(".webp")
|
||||
if webp.exists() and webp.stat().st_mtime >= png.stat().st_mtime:
|
||||
continue
|
||||
with Image.open(png) as im:
|
||||
if max(im.size) > MAX_SIDE:
|
||||
print(f"건너뜀 (아이콘 크기 아님 {im.size[0]}x{im.size[1]}): {png.name}")
|
||||
continue
|
||||
im.convert("RGBA").save(webp, "WEBP", quality=QUALITY, method=6)
|
||||
made += 1
|
||||
print(f"{png.name}: {png.stat().st_size // 1024}KB -> {webp.stat().st_size // 1024}KB")
|
||||
print(f"WebP {made}개 만듦")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user