Supports previewing HEIF/HEIC images#16748
Open
TCOTC wants to merge 6 commits intosiyuan-note:devfrom
Open
Conversation
TCOTC
commented
Jan 16, 2026
| os.RemoveAll(filepath.Join(util.TempDir, "blocktree.msgpack")) // v2.7.2 前旧版的块树数据 | ||
| os.RemoveAll(filepath.Join(util.DataDir, "%")) // v3.0.6 生成的错误历史文件夹 | ||
| os.RemoveAll(filepath.Join(util.TempDir, "blocktree")) // v3.1.0 前旧版的块树数据 | ||
| os.RemoveAll(filepath.Join(util.TempDir, "thumbnails")) // 旧版的缩略图目录 |
Contributor
Author
There was a problem hiding this comment.
确定要合并了再按前两条的格式补充版本号、解决冲突
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Note
经过在 Xcode 的模拟器上测试,在修复 #16747 之前,清理缓存图片的逻辑在 iOS 上不生效。安卓和鸿蒙应该也是一样的。
Note
因为我搞不定在模拟器里安装 Chrome,不清楚 iOS 上的非 Safari 浏览器能不能查看 HEIF 图片。所以代码实现是只有 Safari 浏览器和 iOS APP 能直接查看。
AI 总结:
支持预览 HEIF/HEIC 图片
功能概述
实现了对 HEIF/HEIC 图片格式的完整支持。原始文件保持不变,系统在预览时按需进行格式转换和缩略图生成,确保所有客户端都能正常显示图片。
实现内容
1. 前端支持
.heic和.heif扩展名支持2. 后端处理逻辑
serveHeifConversion函数,当客户端不支持 HEIF 格式时,动态将 HEIF 图片转换为 JPEG 格式返回serveHeifThumbnail函数,生成 HEIF 图片的缩略图isHeifSupported函数,用于检测客户端是否原生支持 HEIF 格式3. 核心转换功能
ConvertHeifToJpeg函数,将 HEIF 文件转换为 JPEG 格式(保持原始尺寸)GenerateHeifThumbnail函数,生成 HEIF 图片的缩略图(最大宽度 520px)fixImageOrientation函数,根据 EXIF 方向信息自动修正图片方向sync.Map和sync.Once实现并发控制,避免同一文件被重复转换技术细节
github.com/jdeng/goheif库进行 HEIF 图片解码github.com/rwcarlsen/goexif库处理 EXIF 方向信息temp/assets-cache/目录下,分为heif/和thumb/两个子目录兼容性
原始设计文档:流程设计.md
参考资料: