mirror of https://github.com/perkeep/perkeep.git
vendor/github.com/rwcarlsen/goexif: update and remove local modifications
Remove goexif local changes (a TODO, README and gofmt) Update to rev: 709fab3d192d7c62f86043caff1e7e3fb0f42bd8 Use dep to prune unused files Change-Id: Icce8885917b798b25eaeed4c98ff393ce0db66b8
This commit is contained in:
parent
57648c6b83
commit
7ed0b7ec5c
|
@ -50,10 +50,15 @@ misc/docker/camlistored/djpeg
|
|||
/vendor/github.com/gopherjs/gopherjs/tests/testdata
|
||||
/vendor/github.com/gorilla/websocket/examples
|
||||
/vendor/github.com/mattn/go-sqlite3/sqlite3_windows.c
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/corrupt
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/example_test.go
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/exif_test.go
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/samples
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/sample1.jpg
|
||||
/vendor/github.com/rwcarlsen/goexif/tiff/sample1.tif
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/corrupt
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/regen_regress.go
|
||||
/vendor/github.com/rwcarlsen/goexif/exif/regress_expected_test.go
|
||||
/vendor/github.com/rwcarlsen/goexif/tiff/tiff_test.go
|
||||
/vendor/github.com/russross/blackfriday/testdata
|
||||
/vendor/github.com/syndtr/goleveldb/leveldb/testutil
|
||||
/vendor/github.com/syndtr/goleveldb/manualtest
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
Syncing updates from upstream goexif
|
||||
====================================
|
||||
|
||||
We do not ship the "samples" directory, nor the "corrupt" one, which contain data for the
|
||||
tests. For this reason, we do not include the _test.go files either, as well as
|
||||
regen_regress.go (which is used to generate some of the data for the tests).
|
||||
|
||||
It is your duty, when updating our goexif third party from upstream, to check that all the
|
||||
tests in the upstream repo pass.
|
|
@ -462,7 +462,6 @@ func tagDegrees(tag *tiff.Tag) (float64, error) {
|
|||
if err != nil {
|
||||
return 0.0, err
|
||||
}
|
||||
// TODO(mpl): make it return an error when parsing a NaN. But upstream.
|
||||
return parseTagDegreesString(s)
|
||||
default:
|
||||
// don't know how to parse value, give up
|
||||
|
@ -575,7 +574,7 @@ func newAppSec(marker byte, r io.Reader) (*appSec, error) {
|
|||
}
|
||||
|
||||
dataLenBytes := make([]byte, 2)
|
||||
for k, _ := range dataLenBytes {
|
||||
for k,_ := range dataLenBytes {
|
||||
c, err := br.ReadByte()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/rwcarlsen/goexif/exif"
|
||||
"github.com/rwcarlsen/goexif/mknote"
|
||||
"github.com/rwcarlsen/goexif/tiff"
|
||||
)
|
||||
|
||||
var mnote = flag.Bool("mknote", false, "try to parse makernote data")
|
||||
var thumb = flag.Bool("thumb", false, "dump thumbail data to stdout (for first listed image file)")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
fnames := flag.Args()
|
||||
|
||||
if *mnote {
|
||||
exif.RegisterParsers(mknote.All...)
|
||||
}
|
||||
|
||||
for _, name := range fnames {
|
||||
f, err := os.Open(name)
|
||||
if err != nil {
|
||||
log.Printf("err on %v: %v", name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
x, err := exif.Decode(f)
|
||||
if err != nil {
|
||||
log.Printf("err on %v: %v", name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if *thumb {
|
||||
data, err := x.JpegThumbnail()
|
||||
if err != nil {
|
||||
log.Fatal("no thumbnail present")
|
||||
}
|
||||
if _, err := os.Stdout.Write(data); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\n---- Image '%v' ----\n", name)
|
||||
x.Walk(Walker{})
|
||||
}
|
||||
}
|
||||
|
||||
type Walker struct{}
|
||||
|
||||
func (_ Walker) Walk(name exif.FieldName, tag *tiff.Tag) error {
|
||||
data, _ := tag.MarshalJSON()
|
||||
fmt.Printf(" %v: %v\n", name, string(data))
|
||||
return nil
|
||||
}
|
|
@ -1,268 +0,0 @@
|
|||
package mknote
|
||||
|
||||
import "github.com/rwcarlsen/goexif/exif"
|
||||
|
||||
// Useful resources used in creating these tables:
|
||||
// http://www.exiv2.org/makernote.html
|
||||
// http://www.exiv2.org/tags-canon.html
|
||||
// http://www.exiv2.org/tags-nikon.html
|
||||
|
||||
// Known Maker Note fields
|
||||
const (
|
||||
// common fields
|
||||
ISOSpeed exif.FieldName = "ISOSpeed"
|
||||
ColorMode = "ColorMode"
|
||||
Quality = "Quality"
|
||||
Sharpening = "Sharpening"
|
||||
Focus = "Focus"
|
||||
FlashSetting = "FlashSetting"
|
||||
FlashDevice = "FlashDevice"
|
||||
WhiteBalanceBias = "WhiteBalanceBias"
|
||||
WB_RBLevels = "WB_RBLevels"
|
||||
ProgramShift = "ProgramShift"
|
||||
ExposureDiff = "ExposureDiff"
|
||||
ISOSelection = "ISOSelection"
|
||||
DataDump = "DataDump"
|
||||
Preview = "Preview"
|
||||
FlashComp = "FlashComp"
|
||||
ISOSettings = "ISOSettings"
|
||||
ImageBoundary = "ImageBoundary"
|
||||
FlashExposureComp = "FlashExposureComp"
|
||||
FlashBracketComp = "FlashBracketComp"
|
||||
ExposureBracketComp = "ExposureBracketComp"
|
||||
ImageProcessing = "ImageProcessing"
|
||||
CropHiSpeed = "CropHiSpeed"
|
||||
ExposureTuning = "ExposureTuning"
|
||||
SerialNumber = "SerialNumber"
|
||||
ImageAuthentication = "ImageAuthentication"
|
||||
ActiveDLighting = "ActiveDLighting"
|
||||
VignetteControl = "VignetteControl"
|
||||
ImageAdjustment = "ImageAdjustment"
|
||||
ToneComp = "ToneComp"
|
||||
AuxiliaryLens = "AuxiliaryLens"
|
||||
LensType = "LensType"
|
||||
Lens = "Lens"
|
||||
FocusDistance = "FocusDistance"
|
||||
DigitalZoom = "DigitalZoom"
|
||||
FlashMode = "FlashMode"
|
||||
ShootingMode = "ShootingMode"
|
||||
AutoBracketRelease = "AutoBracketRelease"
|
||||
LensFStops = "LensFStops"
|
||||
ContrastCurve = "ContrastCurve"
|
||||
ColorHue = "ColorHue"
|
||||
SceneMode = "SceneMode"
|
||||
HueAdjustment = "HueAdjustment"
|
||||
NEFCompression = "NEFCompression"
|
||||
NoiseReduction = "NoiseReduction"
|
||||
LinearizationTable = "LinearizationTable"
|
||||
RawImageCenter = "RawImageCenter"
|
||||
SensorPixelSize = "SensorPixelSize"
|
||||
SceneAssist = "SceneAssist"
|
||||
RetouchHistory = "RetouchHistory"
|
||||
ImageDataSize = "ImageDataSize"
|
||||
ImageCount = "ImageCount"
|
||||
DeletedImageCount = "DeletedImageCount"
|
||||
ShutterCount = "ShutterCount"
|
||||
ImageOptimization = "ImageOptimization"
|
||||
SaturationText = "SaturationText"
|
||||
VariProgram = "VariProgram"
|
||||
ImageStabilization = "ImageStabilization"
|
||||
AFResponse = "AFResponse"
|
||||
HighISONoiseReduction = "HighISONoiseReduction"
|
||||
ToningEffect = "ToningEffect"
|
||||
PrintIM = "PrintIM"
|
||||
CaptureData = "CaptureData"
|
||||
CaptureVersion = "CaptureVersion"
|
||||
CaptureOffsets = "CaptureOffsets"
|
||||
ScanIFD = "ScanIFD"
|
||||
ICCProfile = "ICCProfile"
|
||||
CaptureOutput = "CaptureOutput"
|
||||
Panorama = "Panorama"
|
||||
ImageType = "ImageType"
|
||||
FirmwareVersion = "FirmwareVersion"
|
||||
FileNumber = "FileNumber"
|
||||
OwnerName = "OwnerName"
|
||||
CameraInfo = "CameraInfo"
|
||||
CustomFunctions = "CustomFunctions"
|
||||
ModelID = "ModelID"
|
||||
PictureInfo = "PictureInfo"
|
||||
ThumbnailImageValidArea = "ThumbnailImageValidArea"
|
||||
SerialNumberFormat = "SerialNumberFormat"
|
||||
SuperMacro = "SuperMacro"
|
||||
OriginalDecisionDataOffset = "OriginalDecisionDataOffset"
|
||||
WhiteBalanceTable = "WhiteBalanceTable"
|
||||
LensModel = "LensModel"
|
||||
InternalSerialNumber = "InternalSerialNumber"
|
||||
DustRemovalData = "DustRemovalData"
|
||||
ProcessingInfo = "ProcessingInfo"
|
||||
MeasuredColor = "MeasuredColor"
|
||||
VRDOffset = "VRDOffset"
|
||||
SensorInfo = "SensorInfo"
|
||||
ColorData = "ColorData"
|
||||
|
||||
// Nikon-specific fields
|
||||
Nikon_Version = "Nikon.Version"
|
||||
Nikon_WhiteBalance = "Nikon.WhiteBalance"
|
||||
Nikon_ColorSpace = "Nikon.ColorSpace"
|
||||
Nikon_LightSource = "Nikon.LightSource"
|
||||
Nikon_Saturation = "Nikon_Saturation"
|
||||
Nikon_ShotInfo = "Nikon.ShotInfo" // A sub-IFD
|
||||
Nikon_VRInfo = "Nikon.VRInfo" // A sub-IFD
|
||||
Nikon_PictureControl = "Nikon.PictureControl" // A sub-IFD
|
||||
Nikon_WorldTime = "Nikon.WorldTime" // A sub-IFD
|
||||
Nikon_ISOInfo = "Nikon.ISOInfo" // A sub-IFD
|
||||
Nikon_AFInfo = "Nikon.AFInfo" // A sub-IFD
|
||||
Nikon_ColorBalance = "Nikon.ColorBalance" // A sub-IFD
|
||||
Nikon_LensData = "Nikon.LensData" // A sub-IFD
|
||||
Nikon_SerialNO = "Nikon.SerialNO" // usually starts with "NO="
|
||||
Nikon_FlashInfo = "Nikon.FlashInfo" // A sub-IFD
|
||||
Nikon_MultiExposure = "Nikon.MultiExposure" // A sub-IFD
|
||||
Nikon_AFInfo2 = "Nikon.AFInfo2" // A sub-IFD
|
||||
Nikon_FileInfo = "Nikon.FileInfo" // A sub-IFD
|
||||
Nikon_AFTune = "Nikon.AFTune" // A sub-IFD
|
||||
Nikon3_0x000a = "Nikon3.0x000a"
|
||||
Nikon3_0x009b = "Nikon3.0x009b"
|
||||
Nikon3_0x009f = "Nikon3.0x009f"
|
||||
Nikon3_0x00a3 = "Nikon3.0x00a3"
|
||||
|
||||
// Canon-specific fiends
|
||||
Canon_CameraSettings = "Canon.CameraSettings" // A sub-IFD
|
||||
Canon_ShotInfo = "Canon.ShotInfo" // A sub-IFD
|
||||
Canon_AFInfo = "Canon.AFInfo"
|
||||
Canon_0x0000 = "Canon.0x0000"
|
||||
Canon_0x0003 = "Canon.0x0003"
|
||||
Canon_0x00b5 = "Canon.0x00b5"
|
||||
Canon_0x00c0 = "Canon.0x00c0"
|
||||
Canon_0x00c1 = "Canon.0x00c1"
|
||||
)
|
||||
|
||||
var makerNoteCanonFields = map[uint16]exif.FieldName{
|
||||
0x0000: Canon_0x0000,
|
||||
0x0001: Canon_CameraSettings,
|
||||
0x0002: exif.FocalLength,
|
||||
0x0003: Canon_0x0003,
|
||||
0x0004: Canon_ShotInfo,
|
||||
0x0005: Panorama,
|
||||
0x0006: ImageType,
|
||||
0x0007: FirmwareVersion,
|
||||
0x0008: FileNumber,
|
||||
0x0009: OwnerName,
|
||||
0x000c: SerialNumber,
|
||||
0x000d: CameraInfo,
|
||||
0x000f: CustomFunctions,
|
||||
0x0010: ModelID,
|
||||
0x0012: PictureInfo,
|
||||
0x0013: ThumbnailImageValidArea,
|
||||
0x0015: SerialNumberFormat,
|
||||
0x001a: SuperMacro,
|
||||
0x0026: Canon_AFInfo,
|
||||
0x0083: OriginalDecisionDataOffset,
|
||||
0x00a4: WhiteBalanceTable,
|
||||
0x0095: LensModel,
|
||||
0x0096: InternalSerialNumber,
|
||||
0x0097: DustRemovalData,
|
||||
0x0099: CustomFunctions,
|
||||
0x00a0: ProcessingInfo,
|
||||
0x00aa: MeasuredColor,
|
||||
0x00b4: exif.ColorSpace,
|
||||
0x00b5: Canon_0x00b5,
|
||||
0x00c0: Canon_0x00c0,
|
||||
0x00c1: Canon_0x00c1,
|
||||
0x00d0: VRDOffset,
|
||||
0x00e0: SensorInfo,
|
||||
0x4001: ColorData,
|
||||
}
|
||||
|
||||
// Nikon version 3 Maker Notes fields (used by E5400, SQ, D2H, D70, and newer)
|
||||
var makerNoteNikon3Fields = map[uint16]exif.FieldName{
|
||||
0x0001: Nikon_Version,
|
||||
0x0002: ISOSpeed,
|
||||
0x0003: ColorMode,
|
||||
0x0004: Quality,
|
||||
0x0005: Nikon_WhiteBalance,
|
||||
0x0006: Sharpening,
|
||||
0x0007: Focus,
|
||||
0x0008: FlashSetting,
|
||||
0x0009: FlashDevice,
|
||||
0x000a: Nikon3_0x000a,
|
||||
0x000b: WhiteBalanceBias,
|
||||
0x000c: WB_RBLevels,
|
||||
0x000d: ProgramShift,
|
||||
0x000e: ExposureDiff,
|
||||
0x000f: ISOSelection,
|
||||
0x0010: DataDump,
|
||||
0x0011: Preview,
|
||||
0x0012: FlashComp,
|
||||
0x0013: ISOSettings,
|
||||
0x0016: ImageBoundary,
|
||||
0x0017: FlashExposureComp,
|
||||
0x0018: FlashBracketComp,
|
||||
0x0019: ExposureBracketComp,
|
||||
0x001a: ImageProcessing,
|
||||
0x001b: CropHiSpeed,
|
||||
0x001c: ExposureTuning,
|
||||
0x001d: SerialNumber,
|
||||
0x001e: Nikon_ColorSpace,
|
||||
0x001f: Nikon_VRInfo,
|
||||
0x0020: ImageAuthentication,
|
||||
0x0022: ActiveDLighting,
|
||||
0x0023: Nikon_PictureControl,
|
||||
0x0024: Nikon_WorldTime,
|
||||
0x0025: Nikon_ISOInfo,
|
||||
0x002a: VignetteControl,
|
||||
0x0080: ImageAdjustment,
|
||||
0x0081: ToneComp,
|
||||
0x0082: AuxiliaryLens,
|
||||
0x0083: LensType,
|
||||
0x0084: Lens,
|
||||
0x0085: FocusDistance,
|
||||
0x0086: DigitalZoom,
|
||||
0x0087: FlashMode,
|
||||
0x0088: Nikon_AFInfo,
|
||||
0x0089: ShootingMode,
|
||||
0x008a: AutoBracketRelease,
|
||||
0x008b: LensFStops,
|
||||
0x008c: ContrastCurve,
|
||||
0x008d: ColorHue,
|
||||
0x008f: SceneMode,
|
||||
0x0090: Nikon_LightSource,
|
||||
0x0091: Nikon_ShotInfo,
|
||||
0x0092: HueAdjustment,
|
||||
0x0093: NEFCompression,
|
||||
0x0094: Nikon_Saturation,
|
||||
0x0095: NoiseReduction,
|
||||
0x0096: LinearizationTable,
|
||||
0x0097: Nikon_ColorBalance,
|
||||
0x0098: Nikon_LensData,
|
||||
0x0099: RawImageCenter,
|
||||
0x009a: SensorPixelSize,
|
||||
0x009b: Nikon3_0x009b,
|
||||
0x009c: SceneAssist,
|
||||
0x009e: RetouchHistory,
|
||||
0x009f: Nikon3_0x009f,
|
||||
0x00a0: Nikon_SerialNO,
|
||||
0x00a2: ImageDataSize,
|
||||
0x00a3: Nikon3_0x00a3,
|
||||
0x00a5: ImageCount,
|
||||
0x00a6: DeletedImageCount,
|
||||
0x00a7: ShutterCount,
|
||||
0x00a8: Nikon_FlashInfo,
|
||||
0x00a9: ImageOptimization,
|
||||
0x00aa: SaturationText,
|
||||
0x00ab: VariProgram,
|
||||
0x00ac: ImageStabilization,
|
||||
0x00ad: AFResponse,
|
||||
0x00b0: Nikon_MultiExposure,
|
||||
0x00b1: HighISONoiseReduction,
|
||||
0x00b3: ToningEffect,
|
||||
0x00b7: Nikon_AFInfo2,
|
||||
0x00b8: Nikon_FileInfo,
|
||||
0x00b9: Nikon_AFTune,
|
||||
0x0e00: PrintIM,
|
||||
0x0e01: CaptureData,
|
||||
0x0e09: CaptureVersion,
|
||||
0x0e0e: CaptureOffsets,
|
||||
0x0e10: ScanIFD,
|
||||
0x0e1d: ICCProfile,
|
||||
0x0e1e: CaptureOutput,
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
// Package mknote provides makernote parsers that can be used with goexif/exif.
|
||||
package mknote
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/rwcarlsen/goexif/exif"
|
||||
"github.com/rwcarlsen/goexif/tiff"
|
||||
)
|
||||
|
||||
var (
|
||||
// Canon is an exif.Parser for canon makernote data.
|
||||
Canon = &canon{}
|
||||
// NikonV3 is an exif.Parser for nikon makernote data.
|
||||
NikonV3 = &nikonV3{}
|
||||
// All is a list of all available makernote parsers
|
||||
All = []exif.Parser{Canon, NikonV3}
|
||||
)
|
||||
|
||||
type canon struct{}
|
||||
|
||||
// Parse decodes all Canon makernote data found in x and adds it to x.
|
||||
func (_ *canon) Parse(x *exif.Exif) error {
|
||||
m, err := x.Get(exif.MakerNote)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
mk, err := x.Get(exif.Make)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if val, err := mk.StringVal(); err != nil || val != "Canon" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Canon notes are a single IFD directory with no header.
|
||||
// Reader offsets need to be w.r.t. the original tiff structure.
|
||||
buf := bytes.NewReader(append(make([]byte, m.ValOffset), m.Val...))
|
||||
buf.Seek(int64(m.ValOffset), 0)
|
||||
|
||||
mkNotesDir, _, err := tiff.DecodeDir(buf, x.Tiff.Order)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
x.LoadTags(mkNotesDir, makerNoteCanonFields, false)
|
||||
return nil
|
||||
}
|
||||
|
||||
type nikonV3 struct{}
|
||||
|
||||
// Parse decodes all Nikon makernote data found in x and adds it to x.
|
||||
func (_ *nikonV3) Parse(x *exif.Exif) error {
|
||||
m, err := x.Get(exif.MakerNote)
|
||||
if err != nil {
|
||||
return nil
|
||||
} else if bytes.Compare(m.Val[:6], []byte("Nikon\000")) != 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Nikon v3 maker note is a self-contained IFD (offsets are relative
|
||||
// to the start of the maker note)
|
||||
mkNotes, err := tiff.Decode(bytes.NewReader(m.Val[10:]))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
x.LoadTags(mkNotes.Dirs[0], makerNoteNikon3Fields, false)
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue