### Install goexif/exif Source: https://pkg.go.dev/github.com/rwcarlsen/goexif Use this command to install the exif package for decoding EXIF data. ```bash go get github.com/rwcarlsen/goexif/exif ``` -------------------------------- ### Install goexif/tiff Source: https://pkg.go.dev/github.com/rwcarlsen/goexif Use this command to install the tiff package for decoding TIFF data. ```bash go get github.com/rwcarlsen/goexif/tiff ``` -------------------------------- ### Decode EXIF Data from an Image Source: https://pkg.go.dev/github.com/rwcarlsen/goexif This example demonstrates how to open an image file, decode its EXIF data, and retrieve specific tags like camera model, focal length, date taken, and GPS coordinates. Camera makenote data parsing can be optionally registered. ```go package main import ( "fmt" "log" "os" "github.com/rwcarlsen/goexif/exif" "github.com/rwcarlsen/goexif/mknote" ) func ExampleDecode() { fname := "sample1.jpg" f, err := os.Open(fname) if err != nil { log.Fatal(err) } // Optionally register camera makenote data parsing - currently Nikon and // Canon are supported. exif.RegisterParsers(mknote.All...) x, err := exif.Decode(f) if err != nil { log.Fatal(err) } camModel, _ := x.Get(exif.Model) // normally, don't ignore errors! fmt.Println(camModel.StringVal()) focal, _ := x.Get(exif.FocalLength) numer, denom, _ := focal.Rat2(0) // retrieve first (only) rat. value fmt.Printf("%v/%v", numer, denom) // Two convenience functions exist for date/time taken and GPS coords: tm, _ := x.DateTime() fmt.Println("Taken: ", tm) lat, long, _ := x.LatLong() fmt.Println("lat, long: ", lat, ", ", long) } ``` -------------------------------- ### func (*Exif) Get Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Retrieves a specific EXIF tag by its field name. ```APIDOC ## func (x *Exif) Get(name FieldName) (*tiff.Tag, error) ### Description Retrieves the EXIF tag for the specified field name. ### Parameters #### Request Body - **name** (FieldName) - Required - The name of the EXIF field to retrieve. ### Response #### Success Response (200) - **tiff.Tag** (object) - The requested tag structure. #### Error Response - **TagNotPresentError** - Returned if the tag is known but not present in the data. ``` -------------------------------- ### Get Tag as Rational Number (Numerator/Denominator) Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Returns the i'th value of a tag as a rational number represented by numerator and denominator. Returns an error if the tag's format is not RatVal. Panics if i is out of range. ```go func (t *Tag) Rat2(i int) (num, den int64, err error) ``` -------------------------------- ### Get Tag as Rational Number (big.Rat) Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Returns the i'th value of a tag as a rational number using big.Rat. Returns an error if the tag's format is not RatVal. Panics for zero denominators or out-of-range indices. ```go func (t *Tag) Rat(i int) (*big.Rat, error) ``` -------------------------------- ### Get Tag Value as String Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Returns the tag's value as a string. Returns an error if the tag's format is not StringVal. Panics if i is out of range. ```go func (t *Tag) StringVal() (string, error) ``` -------------------------------- ### Dir String Method Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Returns a string representation of the directory. ```go func (d *Dir) String() string ``` -------------------------------- ### Exif.Walk() Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Walks through all non-nil EXIF fields, calling a provided walker function. ```APIDOC ## Exif.Walk() ### Description Walk calls the Walk method of w with the name and tag for every non-nil EXIF field. If w aborts the walk with an error, that error is returned. ### Method POST (conceptual) ### Endpoint N/A (method on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **w** (Walker) - An interface with a `Walk(name string, tag uint16)` method. ### Request Example ```go // Assuming 'exifData' is an *Exif object type MyWalker struct {} func (mw MyWalker) Walk(name string, tag uint16) error { fmt.Printf("Field: %s, Tag: 0x%X\n", name, tag) // return errors.New("stop walk") to abort return nil } err := exifData.Walk(MyWalker{}) if err != nil { log.Fatal(err) } ``` ### Response #### Success Response (200) - **error** - An error if the walk is aborted by the walker. #### Response Example None ``` -------------------------------- ### Interoperability Fields Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines constants for interoperability related EXIF fields. ```go const ( InteroperabilityIndex FieldName = "InteroperabilityIndex" ) ``` -------------------------------- ### String Representation of Tag Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Returns a nicely formatted string representation of the tag. ```go func (t *Tag) String() string ``` -------------------------------- ### func (*Exif) DateTime Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Retrieves the creation time of the photo from EXIF metadata. ```APIDOC ## func (x *Exif) DateTime() (time.Time, error) ### Description Returns the 'DateTimeOriginal' field. If not found, it attempts to retrieve the 'DateTime' field. If neither is found, it returns a TagNotPresentError. ### Response #### Success Response (200) - **time.Time** (time.Time) - The parsed creation time. #### Error Response - **TagNotPresentError** - Returned if the required tags are missing. ``` -------------------------------- ### Dir Structure Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Provides access to the parsed content of a TIFF Image File Directory. ```go type Dir struct { Tags []*Tag } ``` -------------------------------- ### Format Definitions Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Specifies the Go type equivalent for basic TIFF data types. ```go type Format int const ( IntVal Format = iota FloatVal RatVal StringVal UndefVal OtherVal ) ``` -------------------------------- ### Exif.LoadTags() Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Loads EXIF tags from a TIFF directory into the Exif struct. ```APIDOC ## Exif.LoadTags() ### Description LoadTags loads tags into the available fields from the tiff Directory using the given tagid-fieldname mapping. Used to load makernote and other meta-data. If showMissing is true, tags in d that are not in the fieldMap will be loaded with the FieldName UnknownPrefix followed by the tag ID (in hex format). ### Method POST (conceptual) ### Endpoint N/A (method on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **d** (*tiff.Dir) - The TIFF directory containing the tags. - **fieldMap** (map[uint16]FieldName) - A mapping from tag IDs to field names. - **showMissing** (bool) - If true, unknown tags will be included. ### Request Example ```json { "d": { ... tiff.Dir object ... }, "fieldMap": { "0x0100": "ImageWidth", "0x0102": "BitsPerSample" }, "showMissing": true } ``` ### Response #### Success Response (200) This method does not return a value, but modifies the Exif object it is called on. #### Response Example None ``` -------------------------------- ### Walker Interface Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines the Walker interface for traversing all fields of an Exif object. The Walk method is called for each non-nil EXIF field, and returning an error aborts the traversal. ```go type Walker interface { // Walk is called for each non-nil EXIF field. Returning a non-nil // error aborts the walk/traversal. Walk(name FieldName, tag *tiff.Tag) error } ``` -------------------------------- ### Exif.String() Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Returns a string representation of the EXIF data. ```APIDOC ## Exif.String() ### Description String returns a pretty text representation of the decoded exif data. ### Method GET (conceptual) ### Endpoint N/A (method on an object) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **string** - A human-readable string of the EXIF data. #### Response Example ``` Image Width: 1920 Image Height: 1080 Make: Canon Model: EOS 5D Mark IV ... (other fields) ``` ``` -------------------------------- ### Parser Interface Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines the Parser interface, which allows custom parsing and field loading into an Exif object. Implement this interface to integrate custom EXIF data handling. ```go type Parser interface { // Parse should read data from x and insert parsed fields into x via // LoadTags. Parse(x *Exif) error } ``` -------------------------------- ### ReadAtReader Interface Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Interface required for decoding TIFF tags and directories. ```go type ReadAtReader interface { io.Reader io.ReaderAt } ``` -------------------------------- ### MakerNote Parsers Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/mknote Available parser implementations for processing MakerNote data. ```APIDOC ## MakerNote Parsers ### Available Parsers - **Canon**: Parser for Canon makernote data. - **NikonV3**: Parser for Nikon makernote data. - **All**: A collection containing all available makernote parsers. ``` -------------------------------- ### EXIF MakerNote Field Definitions Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/mknote A reference list of supported EXIF field names categorized by general, Nikon, and Canon specific metadata. ```APIDOC ## EXIF Field Definitions ### General Fields - LensModel - InternalSerialNumber - DustRemovalData - ProcessingInfo - MeasuredColor - VRDOffset - SensorInfo - ColorData ### Nikon-specific Fields - Nikon.Version - Nikon.WhiteBalance - Nikon.ColorSpace - Nikon.LightSource - Nikon_Saturation - Nikon.ShotInfo (Sub-IFD) - Nikon.VRInfo (Sub-IFD) - Nikon.PictureControl (Sub-IFD) - Nikon.WorldTime (Sub-IFD) - Nikon.ISOInfo (Sub-IFD) - Nikon.AFInfo (Sub-IFD) - Nikon.ColorBalance (Sub-IFD) - Nikon.LensData (Sub-IFD) - Nikon.SerialNO - Nikon.FlashInfo (Sub-IFD) - Nikon.MultiExposure (Sub-IFD) - Nikon.AFInfo2 (Sub-IFD) - Nikon.FileInfo (Sub-IFD) - Nikon.AFTune (Sub-IFD) - Nikon3.0x000a - Nikon3.0x009b - Nikon3.0x009f - Nikon3.0x00a3 ### Canon-specific Fields - Canon.CameraSettings (Sub-IFD) - Canon.ShotInfo (Sub-IFD) - Canon.AFInfo - Canon.TimeInfo - Canon.0x0000 - Canon.0x0003 - Canon.0x00b5 - Canon.0x00c0 - Canon.0x00c1 ``` -------------------------------- ### Tag Value Retrieval Methods Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Methods to retrieve tag values as specific types. ```go func (t *Tag) Float(i int) (float64, error) func (t *Tag) Format() Format func (t *Tag) Int(i int) (int, error) func (t *Tag) Int64(i int) (int64, error) ``` -------------------------------- ### Exif.MarshalJSON() Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Implements the JSON marshaler for the Exif struct. ```APIDOC ## Exif.MarshalJSON() ### Description MarshalJson implements the encoding/json.Marshaler interface providing output of all EXIF fields present (names and values). ### Method GET (conceptual) ### Endpoint N/A (method on an object) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **[]byte** - A byte slice representing the JSON encoded EXIF data. - **error** - An error if marshaling fails. #### Response Example ```json { "ImageWidth": 1920, "ImageHeight": 1080, "Make": "Canon" } ``` ``` -------------------------------- ### DataType Definitions Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Defines the basic TIFF tag data types as uint16 constants. ```go type DataType uint16 const ( DTByte DataType = 1 DTAscii DataType = 2 DTShort DataType = 3 DTLong DataType = 4 DTRational DataType = 5 DTSByte DataType = 6 DTUndefined DataType = 7 DTSShort DataType = 8 DTSLong DataType = 9 DTSRational DataType = 10 DTFloat DataType = 11 DTDouble DataType = 12 ) ``` -------------------------------- ### Tag Methods Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Methods available for the Tag type, including JSON marshaling, retrieving rational and string values, and string representation. ```APIDOC ## func (*Tag) MarshalJSON ```go func (t *Tag) MarshalJSON() ([]byte, error) ``` ### Description Marshals the Tag into JSON format. ### Method GET ### Endpoint N/A (Method on a struct) ## func (*Tag) Rat ```go func (t *Tag) Rat(i int) (*big.Rat, error) ``` ### Description Rat returns the tag's i'th value as a rational number. It returns a nil and an error if this tag's Format is not RatVal. It panics for zero deminators or if i is out of range. ### Method GET ### Endpoint N/A (Method on a struct) ## func (*Tag) Rat2 ```go func (t *Tag) Rat2(i int) (num, den int64, err error) ``` ### Description Rat2 returns the tag's i'th value as a rational number represented by a numerator-denominator pair. It returns an error if the tag's Format is not RatVal. It panics if i is out of range. ### Method GET ### Endpoint N/A (Method on a struct) ## func (*Tag) String ```go func (t *Tag) String() string ``` ### Description String returns a nicely formatted version of the tag. ### Method GET ### Endpoint N/A (Method on a struct) ## func (*Tag) StringVal ```go func (t *Tag) StringVal() (string, error) ``` ### Description StringVal returns the tag's value as a string. It returns an error if the tag's Format is not StringVal. It panics if i is out of range. ### Method GET ### Endpoint N/A (Method on a struct) ``` -------------------------------- ### Exif.LatLong() Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Retrieves the latitude and longitude from the EXIF data. ```APIDOC ## Exif.LatLong() ### Description LatLong returns the latitude and longitude of the photo and whether it was present. ### Method GET (conceptual) ### Endpoint N/A (method on an object) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **lat** (float64) - The latitude of the photo. - **long** (float64) - The longitude of the photo. - **err** (error) - An error if retrieval fails. #### Response Example ```json { "lat": 34.0522, "long": -118.2437, "err": null } ``` ``` -------------------------------- ### String Representation of Tiff Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Returns a string representation of the Tiff struct. ```go func (tf *Tiff) String() string ``` -------------------------------- ### Windows-specific EXIF Tags Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines Windows-specific EXIF tags, which are extensions for Windows metadata. ```APIDOC ## Windows-specific EXIF Tags ### Description This section defines Windows-specific EXIF tags. These are extensions to the standard EXIF format used primarily on Windows operating systems for additional metadata. ### Method N/A (Constants Definition) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### func Decode Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Parses EXIF data from an io.Reader and returns a queryable Exif object. ```APIDOC ## func Decode(r io.Reader) (*Exif, error) ### Description Decodes EXIF data from a provided reader (TIFF, JPEG, or raw EXIF block). After decoding, registered parsers are executed. ### Parameters #### Request Body - **r** (io.Reader) - Required - The source reader containing the EXIF data. ### Response #### Success Response (200) - **Exif** (object) - A pointer to the decoded Exif structure. - **error** (error) - Returns nil on success, or an error if decoding fails. ``` -------------------------------- ### Thumbnail JPEG Fields Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines constants for thumbnail JPEG related EXIF fields, including offset and length. ```go const ( ThumbJPEGInterchangeFormat FieldName = "ThumbJPEGInterchangeFormat" // offset to thumb jpeg SOI ThumbJPEGInterchangeFormatLength FieldName = "ThumbJPEGInterchangeFormatLength" // byte length of thumb ) ``` -------------------------------- ### Tag Structure Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Represents the parsed content of a TIFF IFD tag. ```go type Tag struct { // Id is the 2-byte tiff tag identifier. Id uint16 // Type is an integer (1 through 12) indicating the tag value's data type. Type DataType // Count is the number of type Type stored in the tag's value (i.e. the // tag's value is an array of type Type and length Count). Count uint32 // Val holds the bytes that represent the tag's value. Val []byte // ValOffset holds byte offset of the tag value w.r.t. the beginning of the // reader it was decoded from. Zero if the tag value fit inside the offset // field. ValOffset uint32 // contains filtered or unexported fields } ``` -------------------------------- ### EXIF Field Definitions Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines constants for various EXIF fields, including thumbnail, GPS, and interoperability fields. ```APIDOC ## EXIF Field Definitions ### Thumbnail Fields ```go const ( ThumbJPEGInterchangeFormat FieldName = "ThumbJPEGInterchangeFormat" // offset to thumb jpeg SOI ThumbJPEGInterchangeFormatLength FieldName = "ThumbJPEGInterchangeFormatLength" // byte length of thumb ) ``` ### GPS Fields ```go const ( GPSVersionID FieldName = "GPSVersionID" GPSLatitudeRef FieldName = "GPSLatitudeRef" GPSLatitude FieldName = "GPSLatitude" GPSLongitudeRef FieldName = "GPSLongitudeRef" GPSLongitude FieldName = "GPSLongitude" GPSAltitudeRef FieldName = "GPSAltitudeRef" GPSAltitude FieldName = "GPSAltitude" GPSTimeStamp FieldName = "GPSTimeStamp" GPSSatelites FieldName = "GPSSatelites" GPSStatus FieldName = "GPSStatus" GPSMeasureMode FieldName = "GPSMeasureMode" GPSDOP FieldName = "GPSDOP" GPSSpeedRef FieldName = "GPSSpeedRef" GPSSpeed FieldName = "GPSSpeed" GPSTrackRef FieldName = "GPSTrackRef" GPSTrack FieldName = "GPSTrack" GPSImgDirectionRef FieldName = "GPSImgDirectionRef" GPSImgDirection FieldName = "GPSImgDirection" GPSMapDatum FieldName = "GPSMapDatum" GPSDestLatitudeRef FieldName = "GPSDestLatitudeRef" GPSDestLatitude FieldName = "GPSDestLatitude" GPSDestLongitudeRef FieldName = "GPSDestLongitudeRef" GPSDestLongitude FieldName = "GPSDestLongitude" GPSDestBearingRef FieldName = "GPSDestBearingRef" GPSDestBearing FieldName = "GPSDestBearing" GPSDestDistanceRef FieldName = "GPSDestDistanceRef" GPSDestDistance FieldName = "GPSDestDistance" GPSProcessingMethod FieldName = "GPSProcessingMethod" GPSAreaInformation FieldName = "GPSAreaInformation" GPSDateStamp FieldName = "GPSDateStamp" GPSDifferential FieldName = "GPSDifferential" ) ``` ### Interoperability Fields ```go const ( InteroperabilityIndex FieldName = "InteroperabilityIndex" ) ``` ``` -------------------------------- ### Exif.TimeZone() Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Retrieves the time zone information from the EXIF data. ```APIDOC ## Exif.TimeZone() ### Description TimeZone returns the time zone information associated with the EXIF data. ### Method GET (conceptual) ### Endpoint N/A (method on an object) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **location** (*time.Location) - The time zone location. - **err** (error) - An error if retrieval fails. #### Response Example ```json { "location": "UTC", "err": null } ``` ``` -------------------------------- ### Walker Interface Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif The Walker interface is used to traverse all fields of an Exif object. ```APIDOC ## Walker Interface ### Description Walker is the interface used to traverse all fields of an Exif object. The Walk method is called for each non-nil EXIF field. Returning a non-nil error aborts the walk/traversal. ### Interface ```go type Walker interface { // Walk is called for each non-nil EXIF field. Returning a non-nil // error aborts the walk/traversal. Walk(name FieldName, tag *tiff.Tag) error } ``` ``` -------------------------------- ### Marshal JSON for Tag Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff This function is part of the Tag type and is used for JSON marshaling. ```go func (t *Tag) MarshalJSON() ([]byte, error) ``` -------------------------------- ### GPS Fields Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines constants for various GPS related EXIF fields, such as version, latitude, longitude, altitude, and timestamp. ```go const ( GPSVersionID FieldName = "GPSVersionID" GPSLatitudeRef FieldName = "GPSLatitudeRef" GPSLatitude FieldName = "GPSLatitude" GPSLongitudeRef FieldName = "GPSLongitudeRef" GPSLongitude FieldName = "GPSLongitude" GPSAltitudeRef FieldName = "GPSAltitudeRef" GPSAltitude FieldName = "GPSAltitude" GPSTimeStamp FieldName = "GPSTimeStamp" GPSSatelites FieldName = "GPSSatelites" GPSStatus FieldName = "GPSStatus" GPSMeasureMode FieldName = "GPSMeasureMode" GPSDOP FieldName = "GPSDOP" GPSSpeedRef FieldName = "GPSSpeedRef" GPSSpeed FieldName = "GPSSpeed" GPSTrackRef FieldName = "GPSTrackRef" GPSTrack FieldName = "GPSTrack" GPSImgDirectionRef FieldName = "GPSImgDirectionRef" GPSImgDirection FieldName = "GPSImgDirection" GPSMapDatum FieldName = "GPSMapDatum" GPSDestLatitudeRef FieldName = "GPSDestLatitudeRef" GPSDestLatitude FieldName = "GPSDestLatitude" GPSDestLongitudeRef FieldName = "GPSDestLongitudeRef" GPSDestLongitude FieldName = "GPSDestLongitude" GPSDestBearingRef FieldName = "GPSDestBearingRef" GPSDestBearing FieldName = "GPSDestBearing" GPSDestDistanceRef FieldName = "GPSDestDistanceRef" GPSDestDistance FieldName = "GPSDestDistance" GPSProcessingMethod FieldName = "GPSProcessingMethod" GPSAreaInformation FieldName = "GPSAreaInformation" GPSDateStamp FieldName = "GPSDateStamp" GPSDifferential FieldName = "GPSDifferential" ) ``` -------------------------------- ### Primary EXIF Fields Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines primary EXIF fields, often used for common metadata like titles and comments. ```APIDOC ## Primary EXIF Fields ### Description This section defines primary EXIF fields that are commonly used for metadata such as title, comment, author, keywords, and subject. ### Method N/A (Constants Definition) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Standard EXIF Field Names Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines the standard EXIF field names as constants of type FieldName. ```APIDOC ## Standard EXIF Field Names ### Description This section lists the standard EXIF field names that can be used to access metadata from images. ### Method N/A (Constants Definition) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Error Variables Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Represents common errors encountered during TIFF decoding. ```go var ErrShortReadTagValue = errors.New("tiff: short read of tag value") ``` -------------------------------- ### TIFF Decoding API Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff APIs for decoding TIFF files and their components. ```APIDOC ## Package tiff Package tiff implements TIFF decoding as defined in TIFF 6.0 specification. ### Functions #### func Decode(r io.Reader) (*Tiff, error) Decode parses a tiff-encoded file from r and returns a Tiff object. #### func DecodeDir(r ReadAtReader, order binary.ByteOrder) (d *Dir, offset int32, err error) DecodeDir parses a tiff-encoded IFD from r and returns a Dir object. offset is the offset to the next IFD. The first read from r should be at the first byte of the IFD. ReadAt offsets should generally be relative to the beginning of the tiff structure (not relative to the beginning of the IFD). #### func DecodeTag(r ReadAtReader, order binary.ByteOrder) (*Tag, error) DecodeTag parses a tiff-encoded IFD tag from r and returns a Tag object. The first read from r should be the first byte of the tag. ReadAt offsets should generally be relative to the beginning of the tiff structure (not relative to the beginning of the tag). ### Types #### type DataType uint16 DataType represents the basic tiff tag data types. Constants: - DTByte (1) - DTAscii (2) - DTShort (3) - DTLong (4) - DTRational (5) - DTSByte (6) - DTUndefined (7) - DTSShort (8) - DTSLong (9) - DTSRational (10) - DTFloat (11) - DTDouble (12) #### type Dir Dir provides access to the parsed content of a tiff Image File Directory (IFD). Methods: - func (d *Dir) String() string #### type Format int Format specifies the Go type equivalent used to represent the basic tiff data types. Constants: - IntVal (0) - FloatVal (1) - RatVal (2) - StringVal (3) - UndefVal (4) - OtherVal (5) #### type ReadAtReader interface ReadAtReader is used when decoding Tiff tags and directories. Methods: - io.Reader - io.ReaderAt #### type Tag Tag reflects the parsed content of a tiff IFD tag. Fields: - Id (uint16): The 2-byte tiff tag identifier. - Type (DataType): An integer (1 through 12) indicating the tag value's data type. - Count (uint32): The number of type Type stored in the tag's value. - Val ([]byte): The bytes that represent the tag's value. - ValOffset (uint32): Byte offset of the tag value w.r.t. the beginning of the reader it was decoded from. Methods: - func (t *Tag) Float(i int) (float64, error): Returns the tag's i'th value as a float. Returns an error if the tag's Format is not IntVal. Panics if i is out of range. - func (t *Tag) Format() Format: Returns a value indicating which method can be called to retrieve the tag's value properly typed. - func (t *Tag) Int(i int) (int, error): Returns the tag's i'th value as an integer. Returns an error if the tag's Format is not IntVal. Panics if i is out of range. - func (t *Tag) Int64(i int) (int64, error): Returns the tag's i'th value as an integer. Returns an error if the tag's Format is not IntVal. Panics if i is out of range. - func (t *Tag) MarshalJSON() ([]byte, error) - func (t *Tag) Rat(i int) (*big.Rat, error) - func (t *Tag) Rat2(i int) (num, den int64, err error) - func (t *Tag) String() string - func (t *Tag) StringVal() (string, error) #### type Tiff Methods: - func (tf *Tiff) String() string ### Variables #### var ErrShortReadTagValue ErrShortReadTagValue = errors.New("tiff: short read of tag value") ``` -------------------------------- ### Tiff String Method Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff The String method for the Tiff type, providing a string representation. ```APIDOC ## func (*Tiff) String ```go func (tf *Tiff) String() string ``` ### Description String returns a nicely formatted version of the tiff data. ### Method GET ### Endpoint N/A (Method on a struct) ``` -------------------------------- ### DecodeDir Function Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Parses a TIFF-encoded IFD from a reader. ```go func DecodeDir(r ReadAtReader, order binary.ByteOrder) (d *Dir, offset int32, err error) ``` -------------------------------- ### DecodeTag Function Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Parses a TIFF-encoded IFD tag from a reader. ```go func DecodeTag(r ReadAtReader, order binary.ByteOrder) (*Tag, error) ``` -------------------------------- ### Decode TIFF Data Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Parses TIFF-encoded data from an io.Reader. The first read from the reader should be the first byte of the TIFF data. ```go func Decode(r io.Reader) (*Tiff, error) ``` -------------------------------- ### Parser Interface Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif The Parser interface allows for custom parsing and field loading within the Decode function. ```APIDOC ## Parser Interface ### Description Parser allows the registration of custom parsing and field loading in the Decode function. ### Interface ```go type Parser interface { // Parse should read data from x and insert parsed fields into x via // LoadTags. Parse(x *Exif) error } ``` ``` -------------------------------- ### Tiff Struct Definition Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Represents a decoded TIFF data structure, containing Image File Directories (IFDs) and byte-encoding information. ```go type Tiff struct { // Dirs is an ordered slice of the tiff's Image File Directories (IFDs). // The IFD at index 0 is IFD0. Dirs []*Dir // The tiff's byte-encoding (i.e. big/little endian). Order binary.ByteOrder } ``` -------------------------------- ### Tiff Struct and Decode Function Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/tiff Details about the Tiff struct for representing TIFF data and the Decode function for parsing TIFF data from a reader. ```APIDOC ## type Tiff ```go type Tiff struct { // Dirs is an ordered slice of the tiff's Image File Directories (IFDs). // The IFD at index 0 is IFD0. Dirs []*Dir // The tiff's byte-encoding (i.e. big/little endian). Order binary.ByteOrder } ``` ### Description Tiff provides access to a decoded tiff data structure. ## func Decode ```go func Decode(r io.Reader) (*Tiff, error) ``` ### Description Decode parses tiff-encoded data from r and returns a Tiff struct that reflects the structure and content of the tiff data. The first read from r should be the first byte of the tiff-encoded data and not necessarily the first byte of an os.File object. ### Method POST ### Endpoint /websites/pkg_go_dev_github_com_rwcarlsen_goexif/decode ### Parameters #### Query Parameters - **r** (io.Reader) - Required - The reader to decode TIFF data from. ### Response #### Success Response (200) - **Tiff** (*Tiff) - The decoded TIFF data structure. - **error** (error) - An error if decoding fails. ``` -------------------------------- ### TagNotPresentError Type Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Represents an error returned when a requested EXIF field is not found. ```APIDOC ## TagNotPresentError Type ### Description A TagNotPresentError is returned when the requested field is not present in the EXIF. ### Type Definition ```go type TagNotPresentError FieldName ``` ### Error Method ```go func (tag TagNotPresentError) Error() string ``` ``` -------------------------------- ### Error Method for TagNotPresentError Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Implements the Error() method for the TagNotPresentError type, providing a string representation of the error. ```go func (tag TagNotPresentError) Error() string ``` -------------------------------- ### TagNotPresentError Type Source: https://pkg.go.dev/github.com/rwcarlsen/goexif/exif Defines the TagNotPresentError type, which is returned when a requested EXIF field is not found. This error type is an alias for FieldName. ```go type TagNotPresentError FieldName ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.