Commit 72a81d34 authored by Jürgen Enge's avatar Jürgen Enge
Browse files

wsl enhancement

parent df3cc923
...@@ -64,6 +64,9 @@ func NewHistogram(convert, resize, remap string, colormap map[string]string, col ...@@ -64,6 +64,9 @@ func NewHistogram(convert, resize, remap string, colormap map[string]string, col
func (h *Histogram) Exec(file string, args ...interface{}) (interface{}, error) { func (h *Histogram) Exec(file string, args ...interface{}) (interface{}, error) {
colors := make(map[string]float64) colors := make(map[string]float64)
if h.wsl {
file = service.Path2Wsl(file)
}
cmdparam := []string{file, "-resize", h.resize, "-dither", "Riemersma", "-colors", fmt.Sprintf("%d", h.colors), "+dither", "-remap", h.remap, "-format", `%c`, "histogram:info:"} cmdparam := []string{file, "-resize", h.resize, "-dither", "Riemersma", "-colors", fmt.Sprintf("%d", h.colors), "+dither", "-remap", h.remap, "-format", `%c`, "histogram:info:"}
cmdfile := h.convert cmdfile := h.convert
if h.wsl { if h.wsl {
......
...@@ -5,6 +5,9 @@ import ( ...@@ -5,6 +5,9 @@ import (
"github.com/op/go-logging" "github.com/op/go-logging"
"image/color" "image/color"
"os" "os"
"path/filepath"
"regexp"
"strings"
) )
var _logformat = logging.MustStringFormatter( var _logformat = logging.MustStringFormatter(
...@@ -59,3 +62,11 @@ func ParseHexColor(s string) (c color.RGBA, err error) { ...@@ -59,3 +62,11 @@ func ParseHexColor(s string) (c color.RGBA, err error) {
} }
return return
} }
var charRegexp = regexp.MustCompile("^/?([a-zA-Z]):([^:]+)$")
func Path2Wsl(file string) (string) {
if matches := charRegexp.FindStringSubmatch(file); matches != nil {
file = fmt.Sprintf("/mnt/%s/%s", strings.ToLower(matches[1]), filepath.ToSlash(matches[2]))
}
return file
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"context" "context"
"github.com/goph/emperror" "github.com/goph/emperror"
"github.com/op/go-logging" "github.com/op/go-logging"
"gitlab.switch.ch/memoriav/memobase-2020/services/histogram/pkg/service"
"os/exec" "os/exec"
"strings" "strings"
"time" "time"
...@@ -31,6 +32,10 @@ func NewValidateAV(ffmpeg string, timeout time.Duration, wsl bool, log *logging. ...@@ -31,6 +32,10 @@ func NewValidateAV(ffmpeg string, timeout time.Duration, wsl bool, log *logging.
func (h *ValidateAV) Exec(file string, args ...interface{}) (interface{}, error) { func (h *ValidateAV) Exec(file string, args ...interface{}) (interface{}, error) {
colors := make(map[string]int64) colors := make(map[string]int64)
if h.wsl {
file = service.Path2Wsl(file)
}
cmdparam := []string{"-v", "warning", "-i", file, "-f", "null", "-"} cmdparam := []string{"-v", "warning", "-i", file, "-f", "null", "-"}
cmdfile := h.ffmpeg cmdfile := h.ffmpeg
if h.wsl { if h.wsl {
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"context" "context"
"github.com/goph/emperror" "github.com/goph/emperror"
"github.com/op/go-logging" "github.com/op/go-logging"
"gitlab.switch.ch/memoriav/memobase-2020/services/histogram/pkg/service"
"os/exec" "os/exec"
"strings" "strings"
"time" "time"
...@@ -31,6 +32,10 @@ func NewValidateImage(identify string, timeout time.Duration, wsl bool, log *log ...@@ -31,6 +32,10 @@ func NewValidateImage(identify string, timeout time.Duration, wsl bool, log *log
func (h *ValidateImage) Exec(file string, args ...interface{}) (interface{}, error) { func (h *ValidateImage) Exec(file string, args ...interface{}) (interface{}, error) {
colors := make(map[string]int64) colors := make(map[string]int64)
if h.wsl {
file = service.Path2Wsl(file)
}
cmdparam := []string{"-verbose", file} cmdparam := []string{"-verbose", file}
cmdfile := h.identify cmdfile := h.identify
if h.wsl { if h.wsl {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment