mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Image OCR supports more formats https://github.com/siyuan-note/siyuan/issues/16418
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
cfc539b84a
commit
d06b370077
1 changed files with 22 additions and 2 deletions
|
|
@ -182,9 +182,29 @@ func RemoveAssetText(asset string) {
|
||||||
assetsTextsChanged.Store(true)
|
assetsTextsChanged.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tesseractExts = []string{
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".jpeg",
|
||||||
|
".tif",
|
||||||
|
".tiff",
|
||||||
|
".bmp",
|
||||||
|
".gif",
|
||||||
|
".webp",
|
||||||
|
".pbm",
|
||||||
|
".pgm",
|
||||||
|
".ppm",
|
||||||
|
".pnm",
|
||||||
|
}
|
||||||
|
|
||||||
func IsTesseractExtractable(p string) bool {
|
func IsTesseractExtractable(p string) bool {
|
||||||
lowerName := strings.ToLower(p)
|
lowerName := strings.ToLower(p)
|
||||||
return strings.HasSuffix(lowerName, ".png") || strings.HasSuffix(lowerName, ".jpg") || strings.HasSuffix(lowerName, ".jpeg")
|
for _, ext := range tesseractExts {
|
||||||
|
if strings.HasSuffix(lowerName, ext) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// tesseractOCRLock 用于 Tesseract OCR 加锁串行执行提升稳定性 https://github.com/siyuan-note/siyuan/issues/7265
|
// tesseractOCRLock 用于 Tesseract OCR 加锁串行执行提升稳定性 https://github.com/siyuan-note/siyuan/issues/7265
|
||||||
|
|
@ -300,7 +320,7 @@ func InitTesseract() {
|
||||||
|
|
||||||
langs := getTesseractLangs()
|
langs := getTesseractLangs()
|
||||||
if 1 > len(langs) {
|
if 1 > len(langs) {
|
||||||
logging.LogWarnf("no tesseract langs found")
|
logging.LogWarnf("no tesseract langs found, disabling tesseract-ocr")
|
||||||
TesseractEnabled = false
|
TesseractEnabled = false
|
||||||
tesseractInited.Store(true)
|
tesseractInited.Store(true)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue