webp_server_go/encoder/rawconvert.go
Nova Kwok d83f6667cc
Refine convert part (#303)
* Refine convert part

* Only open image once

* More refine
2023-12-16 20:12:42 +01:00

23 lines
467 B
Go

package encoder
import (
"path/filepath"
"github.com/jeremytorres/rawparser"
)
func ConvertRawToJPG(rawPath, optimizedPath string) (string, bool) {
parser, _ := rawparser.NewNefParser(true)
info := &rawparser.RawFileInfo{
File: rawPath,
Quality: 100,
DestDir: optimizedPath,
}
_, err := parser.ProcessFile(info)
if err == nil {
_, file := filepath.Split(rawPath)
return optimizedPath + file + "_extracted.jpg", true
}
return rawPath, false
}