Skip to content

blurhash の実装をしようとしました。#75

Merged
totegamma merged 3 commits into
mainfrom
blurhash
May 10, 2026
Merged

blurhash の実装をしようとしました。#75
totegamma merged 3 commits into
mainfrom
blurhash

Conversation

@inugamine
Copy link
Copy Markdown
Contributor

No description provided.

@inugamine
Copy link
Copy Markdown
Contributor Author

画像添付時にblurhashを計算して投稿データに含めるようにし、画像表示時にはblurhashをプレースホルダーとして表示するようにしました。app版・web版の両方に対応しています。

変更内容

投稿側(blurhash計算・送信)

  • computeBlurhash(file: File) ユーティリティを追加
    • OffscreenCanvas で画像を32px程度にリサイズしてから blurhashencode() で計算
    • 画像以外のファイル(GLB等)は undefined を返しスキップ
    • component: (4, 3)
  • Composer.tsxhandleSubmituploadImagecomputeBlurhashPromise.all で並行実行し、mediasblurhash フィールドを含めて投稿

表示側(blurhashデコード・プレースホルダー表示)

  • BlurhashImage コンポーネントを追加
    • blurhash が指定されていれば、decode() でcanvasにぼかし画像を描画し、画像ロード中にプレースホルダーとして表示
    • 画像ロード完了後に0.3秒フェードインで切り替え
    • blurhash がない既存投稿は従来通りの <img> 表示にフォールバック
  • MediaMessage.tsx の画像表示を <img><BlurhashImage> に差し替え

変更ファイル

新規

  • app/src/utils/computeBlurhash.ts
  • web/src/utils/computeBlurhash.ts
  • app/src/components/BlurhashImage.tsx
  • web/src/components/BlurhashImage.tsx

変更

  • app/src/components/Composer.tsx
  • web/src/components/Composer.tsx
  • app/src/components/message/MediaMessage.tsx
  • web/src/components/message/MediaMessage.tsx

依存パッケージ

  • blurhash を app / web 両ワークスペースに追加

Copy link
Copy Markdown
Member

@totegamma totegamma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!!!!!

@totegamma totegamma merged commit 3874433 into main May 10, 2026
1 check passed
@totegamma totegamma deleted the blurhash branch May 10, 2026 11:37
@inugamine inugamine mentioned this pull request May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants