mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-17 22:25:29 +01:00
🎨 Improve image export size for database assets fields https://github.com/siyuan-note/siyuan/issues/16470
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
6ee0b663e2
commit
3e6e5fa3a4
2 changed files with 26 additions and 4 deletions
|
|
@ -51,6 +51,24 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func GetAssetImgSize(assetPath string) (width, height int) {
|
||||
absPath, err := GetAssetAbsPath(assetPath)
|
||||
if err != nil {
|
||||
logging.LogErrorf("get asset [%s] abs path failed: %s", assetPath, err)
|
||||
return
|
||||
}
|
||||
|
||||
img, err := imaging.Open(absPath)
|
||||
if err != nil {
|
||||
logging.LogErrorf("open asset image [%s] failed: %s", absPath, err)
|
||||
return
|
||||
}
|
||||
|
||||
width = img.Bounds().Dx()
|
||||
height = img.Bounds().Dy()
|
||||
return
|
||||
}
|
||||
|
||||
func GetAssetPathByHash(hash string) string {
|
||||
assetHash := cache.GetAssetHash(hash)
|
||||
if nil == assetHash {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue