generated from bep/golibtemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework implementation to use exiftool as the facit
- Loading branch information
Showing
181 changed files
with
11,149 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,44 @@ | ||
on: | ||
push: | ||
branches: [ main ] | ||
branches: [main] | ||
pull_request: | ||
name: Test | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.21.x,1.22.x] | ||
go-version: [1.21.x, 1.22.x] | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Install staticcheck | ||
run: go install honnef.co/go/tools/cmd/staticcheck@latest | ||
shell: bash | ||
- name: Install golint | ||
run: go install golang.org/x/lint/golint@latest | ||
shell: bash | ||
- name: Update PATH | ||
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||
shell: bash | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Fmt | ||
if: matrix.platform != 'windows-latest' # :( | ||
run: "diff <(gofmt -d .) <(printf '')" | ||
shell: bash | ||
- name: Vet | ||
run: go vet ./... | ||
- name: Staticcheck | ||
run: staticcheck ./... | ||
- name: Lint | ||
run: golint ./... | ||
- name: Test | ||
run: go test -race ./... | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Install staticcheck | ||
run: go install honnef.co/go/tools/cmd/staticcheck@latest | ||
shell: bash | ||
- name: Install golint | ||
run: go install golang.org/x/lint/golint@latest | ||
shell: bash | ||
- name: Update PATH | ||
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||
shell: bash | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Fmt | ||
if: matrix.platform != 'windows-latest' # :( | ||
run: "diff <(gofmt -d .) <(printf '')" | ||
shell: bash | ||
- name: Vet | ||
run: go vet ./... | ||
- name: Staticcheck | ||
run: staticcheck ./... | ||
- name: Lint | ||
run: golint ./... | ||
- name: Test | ||
run: go test -race ./... -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4.0.1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
[![Tests on Linux, MacOS and Windows](https://github.com/bep/imagemeta/workflows/Test/badge.svg)](https://github.com/bep/imagemeta/actions?query=workflow:Test) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/bep/imagemeta)](https://goreportcard.com/report/github.com/bep/imagemeta) | ||
[![codecov](https://codecov.io/gh/bep/imagemeta/branch/master/graph/badge.svg)](https://codecov.io/gh/bep/imagemeta) | ||
[![GoDoc](https://godoc.org/github.com/bep/imagemeta?status.svg)](https://godoc.org/github.com/bep/imagemeta) | ||
|
||
# Work in progress | ||
|
||
This is not ready, yet, but the goal is to use this as the library to read image metadata in Hugo. The existing Go libraries I have found is not maintained anymore and too complex to build on top of. The goal of this library is to be relatively small and simple, but I may prove myself wrong. | ||
## When in doubt, Exiftools is right | ||
|
||
The output of this library is tested against `exiftool -n -json`. This means, for example, that: | ||
|
||
* We use f-numbers and not APEX for aperture values. | ||
* We use seconds and not APEX for shutter speed values. | ||
* EXIF field definitions are fetched from this table: https://exiftool.org/TagNames/EXIF.html | ||
* IPTC field definitions are fetched from this table: https://exiftool.org/TagNames/IPTC.html | ||
* The XMP handling is currently very simple, you can supply your own XMP handler (see the `HandleXMP` option) if you need more. | ||
|
||
|
||
## Development | ||
|
||
Many of the tests depends on generated golden files. To update these, run: | ||
|
||
```bash | ||
go generate ./gen | ||
``` | ||
|
||
Note that you need a working `exiftool` and updated binary in your `PATH` for this to work. This was tested OK with: | ||
|
||
``` | ||
exiftool -ver | ||
12.76 | ||
``` |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//go:generate go run main.go | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
outDir := "testdata_exiftool" | ||
os.RemoveAll(outDir) | ||
if err := os.MkdirAll(outDir, 0o755); err != nil { | ||
log.Fatal(err) | ||
} | ||
base := "../testdata" | ||
|
||
if err := filepath.Walk(base, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
if info.IsDir() || strings.HasPrefix(info.Name(), ".") { | ||
return nil | ||
} | ||
|
||
basePath := strings.TrimPrefix(path, base) | ||
|
||
var buf bytes.Buffer | ||
cmd := exec.Command("exiftool", path, "-json", "-n", "-g", "-e") | ||
cmd.Stdout = &buf | ||
cmd.Stderr = os.Stderr | ||
|
||
if err := cmd.Run(); err != nil { | ||
return err | ||
} | ||
|
||
outFilename := filepath.Join(outDir, basePath+".json") | ||
if err := os.MkdirAll(filepath.Dir(outFilename), 0o755); err != nil { | ||
return err | ||
} | ||
|
||
if err := os.WriteFile(outFilename, buf.Bytes(), 0o644); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
Oops, something went wrong.