mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 06:22:25 -05:00
use exif-terminator
This commit is contained in:
parent
589bb9df02
commit
7d024ce74d
117 changed files with 3873 additions and 8725 deletions
21
vendor/github.com/dsoprea/go-jpeg-image-structure/.travis.yml
generated
vendored
21
vendor/github.com/dsoprea/go-jpeg-image-structure/.travis.yml
generated
vendored
|
|
@ -1,21 +0,0 @@
|
|||
language: go
|
||||
go:
|
||||
- master
|
||||
- stable
|
||||
- "1.14"
|
||||
- "1.13"
|
||||
- "1.12"
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
install:
|
||||
- go get -t ./...
|
||||
script:
|
||||
# v1
|
||||
- go test -v .
|
||||
# v2
|
||||
- cd v2
|
||||
- go test -v ./... -coverprofile=coverage.txt -covermode=atomic
|
||||
- cd ..
|
||||
after_success:
|
||||
- cd v2
|
||||
- curl -s https://codecov.io/bash | bash
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
[](https://travis-ci.org/dsoprea/go-jpeg-image-structure)
|
||||
[](https://codecov.io/gh/dsoprea/go-jpeg-image-structure)
|
||||
[](https://travis-ci.org/dsoprea/go-jpeg-image-structure/v2)
|
||||
[](https://codecov.io/gh/dsoprea/go-jpeg-image-structure)
|
||||
[](https://goreportcard.com/report/github.com/dsoprea/go-jpeg-image-structure/v2)
|
||||
[](https://godoc.org/github.com/dsoprea/go-jpeg-image-structure/v2)
|
||||
|
||||
|
|
@ -3,11 +3,14 @@ package jpegstructure
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"image"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"image/jpeg"
|
||||
|
||||
"github.com/dsoprea/go-logging"
|
||||
"github.com/dsoprea/go-utility/image"
|
||||
"github.com/dsoprea/go-utility/v2/image"
|
||||
)
|
||||
|
||||
// JpegMediaParser is a `riimage.MediaParser` that knows how to parse JPEG
|
||||
|
|
@ -122,6 +125,14 @@ func (jmp *JpegMediaParser) LooksLikeFormat(data []byte) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// GetImage returns an image.Image-compatible struct.
|
||||
func (jmp *JpegMediaParser) GetImage(r io.Reader) (img image.Image, err error) {
|
||||
img, err = jpeg.Decode(r)
|
||||
log.PanicIf(err)
|
||||
|
||||
return img, nil
|
||||
}
|
||||
|
||||
var (
|
||||
// Enforce interface conformance.
|
||||
_ riimage.MediaParser = new(JpegMediaParser)
|
||||
|
|
@ -8,11 +8,12 @@ import (
|
|||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/dsoprea/go-exif/v2"
|
||||
"github.com/dsoprea/go-exif/v3"
|
||||
"github.com/dsoprea/go-exif/v3/common"
|
||||
"github.com/dsoprea/go-iptc"
|
||||
"github.com/dsoprea/go-logging"
|
||||
"github.com/dsoprea/go-photoshop-info-format"
|
||||
"github.com/dsoprea/go-utility/image"
|
||||
"github.com/dsoprea/go-utility/v2/image"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -125,7 +126,9 @@ func (s *Segment) Exif() (rootIfd *exif.Ifd, data []byte, err error) {
|
|||
|
||||
jpegLogger.Debugf(nil, "Attempting to parse (%d) byte EXIF blob (Exif).", len(rawExif))
|
||||
|
||||
im := exif.NewIfdMappingWithStandard()
|
||||
im, err := exifcommon.NewIfdMappingWithStandard()
|
||||
log.PanicIf(err)
|
||||
|
||||
ti := exif.NewTagIndex()
|
||||
|
||||
_, index, err := exif.Collect(im, ti, rawExif)
|
||||
|
|
@ -150,7 +153,7 @@ func (s *Segment) FlatExif() (exifTags []exif.ExifTag, err error) {
|
|||
|
||||
jpegLogger.Debugf(nil, "Attempting to parse (%d) byte EXIF blob (FlatExif).", len(rawExif))
|
||||
|
||||
exifTags, err = exif.GetFlatExifData(rawExif)
|
||||
exifTags, _, err = exif.GetFlatExifData(rawExif, nil)
|
||||
log.PanicIf(err)
|
||||
|
||||
return exifTags, nil
|
||||
|
|
@ -8,7 +8,8 @@ import (
|
|||
"crypto/sha1"
|
||||
"encoding/binary"
|
||||
|
||||
"github.com/dsoprea/go-exif/v2"
|
||||
"github.com/dsoprea/go-exif/v3"
|
||||
"github.com/dsoprea/go-exif/v3/common"
|
||||
"github.com/dsoprea/go-iptc"
|
||||
"github.com/dsoprea/go-logging"
|
||||
)
|
||||
|
|
@ -241,11 +242,31 @@ func (sl *SegmentList) ConstructExifBuilder() (rootIb *exif.IfdBuilder, err erro
|
|||
}()
|
||||
|
||||
rootIfd, _, err := sl.Exif()
|
||||
log.PanicIf(err)
|
||||
if log.Is(err, exif.ErrNoExif) == true {
|
||||
// No EXIF. Just create a boilerplate builder.
|
||||
|
||||
ib := exif.NewIfdBuilderFromExistingChain(rootIfd)
|
||||
im := exifcommon.NewIfdMapping()
|
||||
|
||||
return ib, nil
|
||||
err := exifcommon.LoadStandardIfds(im)
|
||||
log.PanicIf(err)
|
||||
|
||||
ti := exif.NewTagIndex()
|
||||
|
||||
rootIb :=
|
||||
exif.NewIfdBuilder(
|
||||
im,
|
||||
ti,
|
||||
exifcommon.IfdStandardIfdIdentity,
|
||||
exifcommon.EncodeDefaultByteOrder)
|
||||
|
||||
return rootIb, nil
|
||||
} else if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
rootIb = exif.NewIfdBuilderFromExistingChain(rootIfd)
|
||||
|
||||
return rootIb, nil
|
||||
}
|
||||
|
||||
// DumpExif returns an unstructured list of tags (useful when just reviewing).
|
||||
Loading…
Add table
Add a link
Reference in a new issue