mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
* Better config * print to log * Upgrade golang.org/x/net * Tidy go mods * export WebpConfig * Add TestConvertRawToJPG * Add TestConvertRawToJPG * Update Integration Tests UA * Add README for supporting NEF --------- Co-authored-by: Benny <benny.think@gmail.com>
28 lines
652 B
Go
28 lines
652 B
Go
package encoder
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/jeremytorres/rawparser"
|
|
)
|
|
|
|
func ConvertRawToJPG(rawPath, optimizedPath string) (string, bool) {
|
|
if !strings.HasSuffix(strings.ToLower(rawPath), ".nef") {
|
|
// Maybe can use rawParser to convert other raw files to jpg, but I haven't tested it
|
|
return rawPath, false
|
|
}
|
|
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
|
|
}
|