diff --git a/.travis.yml b/.travis.yml index 640ebce..a7c2146 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.7 + - 1.20 addons: apt: diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json deleted file mode 100644 index f241694..0000000 --- a/Godeps/Godeps.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "ImportPath": "github.com/cotap/prism", - "GoVersion": "go1.7", - "GodepVersion": "v77", - "Packages": [ - "./..." - ], - "Deps": [ - { - "ImportPath": "github.com/rwcarlsen/goexif/exif", - "Rev": "709fab3d192d7c62f86043caff1e7e3fb0f42bd8" - }, - { - "ImportPath": "github.com/rwcarlsen/goexif/tiff", - "Rev": "709fab3d192d7c62f86043caff1e7e3fb0f42bd8" - }, - { - "ImportPath": "github.com/stretchr/testify/assert", - "Comment": "v1.0", - "Rev": "232e8563676cd15c3a36ba5e675ad4312ac4cb11" - } - ] -} diff --git a/Makefile b/Makefile index 52464c3..53f03b9 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,12 @@ all: test deps: - @which godep > /dev/null || go get github.com/tools/godep - @export CGO_CFLAGS_ALLOW=-L.*; godep go install + @export CGO_CFLAGS_ALLOW=-L.*; go install test: deps - @export CGO_CFLAGS_ALLOW=-L.*; go list ./... | grep -v /vendor/ | xargs -n1 godep go test + @export CGO_CFLAGS_ALLOW=-L.*; go list ./... | grep -v /vendor/ | xargs -n1 go test bench: deps - @export CGO_CFLAGS_ALLOW=-L.*; go list ./... | grep -v /vendor/ | xargs -n1 godep go test -run=XXX -benchtime=1s -bench=. + @export CGO_CFLAGS_ALLOW=-L.*; go list ./... | grep -v /vendor/ | xargs -n1 go test -run=XXX -benchtime=1s -bench=. .PNONY: all deps test diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..0bbe387 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/cotap/prism + +go 1.19 + +require ( + github.com/rwcarlsen/goexif v0.0.0-20150520140647-709fab3d192d + github.com/stretchr/testify v0.0.0-20150527144555-232e8563676c +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..864abb3 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/rwcarlsen/goexif v0.0.0-20150520140647-709fab3d192d h1:0/OVHHIrQqGZxHRbrX3tJx95MkIbzV44KE66ZGkhH+0= +github.com/rwcarlsen/goexif v0.0.0-20150520140647-709fab3d192d/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= +github.com/stretchr/testify v0.0.0-20150527144555-232e8563676c h1:K56CZP/W9Pm5E3ypakxzGPHfgy+kH3qbGPl+2BZ3o60= +github.com/stretchr/testify v0.0.0-20150527144555-232e8563676c/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/image.go b/image.go index 9f4de51..254ab4b 100644 --- a/image.go +++ b/image.go @@ -53,9 +53,11 @@ func Decode(r io.Reader) (img *Image, err error) { return } + fmt.Printf("data: %v\n", unsafe.Pointer(&b[0])) + fmt.Printf("dataSize: %v\n", C.uint(len(b))) iplImage := C.prismDecode(unsafe.Pointer(&b[0]), C.uint(len(b))) if iplImage == nil { - err = errors.New("Unable to decode image") + err = errors.New("unable to decode image") return } diff --git a/prism.c b/prism.c index 2a2e816..8509179 100644 --- a/prism.c +++ b/prism.c @@ -1,4 +1,5 @@ #include +#include int isRecoverableError(char* errorStr) { if (!strcmp(errorStr, "Invalid SOS parameters for sequential JPEG") || diff --git a/vendor/github.com/rwcarlsen/goexif/exif/regen_regress.go b/vendor/github.com/rwcarlsen/goexif/exif/regen_regress.go deleted file mode 100644 index 17bac52..0000000 --- a/vendor/github.com/rwcarlsen/goexif/exif/regen_regress.go +++ /dev/null @@ -1,79 +0,0 @@ -// +build ignore - -package main - -import ( - "flag" - "fmt" - "io" - "log" - "os" - "path/filepath" - "strings" - - "github.com/rwcarlsen/goexif/exif" - "github.com/rwcarlsen/goexif/tiff" -) - -func main() { - flag.Parse() - fname := flag.Arg(0) - - dst, err := os.Create(fname) - if err != nil { - log.Fatal(err) - } - defer dst.Close() - - dir, err := os.Open("samples") - if err != nil { - log.Fatal(err) - } - defer dir.Close() - - names, err := dir.Readdirnames(0) - if err != nil { - log.Fatal(err) - } - for i, name := range names { - names[i] = filepath.Join("samples", name) - } - makeExpected(names, dst) -} - -func makeExpected(files []string, w io.Writer) { - fmt.Fprintf(w, "package exif\n\n") - fmt.Fprintf(w, "var regressExpected = map[string]map[FieldName]string{\n") - - for _, name := range files { - f, err := os.Open(name) - if err != nil { - continue - } - - x, err := exif.Decode(f) - if err != nil { - f.Close() - continue - } - - fmt.Fprintf(w, "\"%v\": map[FieldName]string{\n", filepath.Base(name)) - x.Walk(®resswalk{w}) - fmt.Fprintf(w, "},\n") - f.Close() - } - fmt.Fprintf(w, "}") -} - -type regresswalk struct { - wr io.Writer -} - -func (w *regresswalk) Walk(name exif.FieldName, tag *tiff.Tag) error { - if strings.HasPrefix(string(name), exif.UnknownPrefix) { - fmt.Fprintf(w.wr, "\"%v\": `%v`,\n", name, tag.String()) - } else { - fmt.Fprintf(w.wr, "%v: `%v`,\n", name, tag.String()) - } - return nil -} diff --git a/vendor/github.com/stretchr/testify/LICENCE.txt b/vendor/github.com/stretchr/testify/LICENCE.txt deleted file mode 100644 index a009ba4..0000000 --- a/vendor/github.com/stretchr/testify/LICENCE.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell - -Please consider promoting this project if you find it useful. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/modules.txt b/vendor/modules.txt new file mode 100644 index 0000000..ee46e1b --- /dev/null +++ b/vendor/modules.txt @@ -0,0 +1,7 @@ +# github.com/rwcarlsen/goexif v0.0.0-20150520140647-709fab3d192d +## explicit +github.com/rwcarlsen/goexif/exif +github.com/rwcarlsen/goexif/tiff +# github.com/stretchr/testify v0.0.0-20150527144555-232e8563676c +## explicit +github.com/stretchr/testify/assert