Skip to content

Commit

Permalink
stub out exif service per issue #72
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Apr 19, 2020
1 parent d229b89 commit cf9cb4c
Show file tree
Hide file tree
Showing 15 changed files with 2,011 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
Palette PaletteConfig `json:"palette,omitempty"`
BlurHash BlurHashConfig `json:"blurhash,omitempty"`
ImageHash ImageHashConfig `json:"imagehash,omitempty"`
Exif ExifConfig `json:"exif,omitempty"`
Custom interface{} `json:"custom,omitempty"`
}

Expand All @@ -48,8 +49,9 @@ type BlurHashConfig struct {
Size int `json:"size"`
}

type ImageHashConfig struct {
}
type ImageHashConfig struct {}

type ExifConfig struct {}

type LevelConfig struct {
Compliance string `json:"compliance"`
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/koyachi/go-atkinson v0.0.0-20141206131144-dacd7cb9e0c5
github.com/muesli/smartcrop v0.3.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/rwcarlsen/goexif v0.0.0-20190401000000-9e8deecbddbd4989a3e8d003684b783412b41e7a
github.com/sfomuseum/go-flags v0.0.4
github.com/whosonfirst/algnhsa v0.1.0
github.com/whosonfirst/go-sanitize v0.1.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/rwcarlsen/goexif v0.0.0-20190401000000-9e8deecbddbd4989a3e8d003684b783412b41e7a h1:Vh5bLI9rG6mBx+0dMNUPGAS6Ps/7mSETZniqvHUEznY=
github.com/rwcarlsen/goexif v0.0.0-20190401000000-9e8deecbddbd4989a3e8d003684b783412b41e7a/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
github.com/sfomuseum/go-flags v0.0.4 h1:dCyG9891QspfnSVtZI/ueEJ/LYweHtXPv2yubqUsH+I=
github.com/sfomuseum/go-flags v0.0.4/go.mod h1:54KCZIGmvZkIOrSCHSNMvgSTKH2gJRJyISH+AiI+55w=
Expand Down
71 changes: 71 additions & 0 deletions service/exif.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package service

import (
"bytes"
"context"
"github.com/rwcarlsen/goexif/exif"
"github.com/rwcarlsen/goexif/mknote"
iiifconfig "github.com/go-iiif/go-iiif/config"
iiifimage "github.com/go-iiif/go-iiif/image"
_ "log"
)

func init() {

ctx := context.Background()
err := RegisterService(ctx, "exif", initExifService)

if err != nil {
panic(err)
}
}

func initExifService(ctx context.Context, cfg *iiifconfig.Config, im iiifimage.Image) (Service, error) {
return NewExifService(cfg.Exif, im)
}

type ExifService struct {
Service `json:",omitempty"`
ExifContext string `json:"@context"`
ExifProfile string `json:"profile"`
ExifLabel string `json:"label"`
ExifData *exif.Exif `json:"data"`
}

func (s *ExifService) Context() string {
return s.ExifContext
}

func (s *ExifService) Profile() string {
return s.ExifProfile
}

func (s *ExifService) Label() string {
return s.ExifLabel
}

func (s *ExifService) Value() interface{} {
return s.ExifData
}

func NewExifService(cfg iiifconfig.ExifConfig, image iiifimage.Image) (Service, error) {

br := bytes.NewReader(image.Body())

exif.RegisterParsers(mknote.All...)

data, err := exif.Decode(br)

if err != nil {
return nil, err
}

s := ExifService{
ExifContext: "x-urn:service:go-iiif#exif",
ExifProfile: "x-urn:service:go-iiif#exif",
ExifLabel: "x-urn:service:go-iiif#exif",
ExifData: data,
}

return &s, nil
}
24 changes: 24 additions & 0 deletions vendor/github.com/rwcarlsen/goexif/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/rwcarlsen/goexif/exif/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cf9cb4c

Please sign in to comment.