Commit Graph

57 Commits (903910b6a7ce4165fe935d413d3e0edd2fcea947)

Author SHA1 Message Date
Dustin Oprea 9aa2497f7b Revert "type.go: Deinegrated `ErrUnhandledUnknownTypedTag`"
This reverts commit 4f2f9044e6.

Reintroduces errors from `UndefinedValue()` when the undefined-type is
unhandled.

- We now just return it rather than panic with it so that we can check
  for it directly rather than use `log.Is()`.

- We've updated the checks across the code accordingly.
2020-01-01 09:05:06 -05:00
Dustin Oprea 78e9e28053 ifd_enumerate_test.go: Moved and refactored some ITEVR tests to be for ValueContext instead
Per our recent change to deimplement ITEVRs.

- ifd_enumerate_test.go: Fixed some test naming.
- ifd_builder_test.go: Dropped some now-unnecessary implementations of
  ITEVRs.
2020-01-01 02:22:28 -05:00
Dustin Oprea 4f2f9044e6 type.go: Deinegrated `ErrUnhandledUnknownTypedTag`
Not actually used anywhere.
2019-12-31 07:39:41 -05:00
Dustin Oprea fb1db098b9 value_context.go: Add and integrate `(*ValueContext).Undefined()` method 2019-12-31 06:45:05 -05:00
Dustin Oprea 71b242c269 value_context.go: We now store the IFD-path and tag-ID on the value-context
This allows us to add an API for accessing an undefined-value/structure
directly on ValueContext.

- ifd_tag_entry.go: Fixed several methods on `IfdTagEntry` to be by-
  reference. It was a latent bug that they weren't.

- value_context.go: Added `newValueContextFromTag` to streamline
  the changes above.
2019-12-31 06:45:05 -05:00
Dustin Oprea e6b94637a3 Eliminate unnecessary byte-order code verbosity 2019-12-29 21:20:40 -05:00
Dustin Oprea 69821c417f value_context.go: ValueContext now embeds value processing
The upshot of this is that generating a list of type-correct slices or a
string from a tag's value is now stupidly easy.

- Broke parsing into an independent type (parser.go:Parser).

- Moved primary value-processing logic to `ValueContext` so that it
  coexists with the actual data (though as much basic functionality as
  possible is implemented independently and reused here). This
  eliminates extremely ridiculously obtuse usage procedure.

- Deprecated almost all existing TagType functionality (in order to
  distance us from this now-legacy usage pattern). Existing
  functionality maintained for now. We'll drop it when we do the next
  release major.

- `ValueContext` is now passed by reference.
2019-12-29 05:48:34 -05:00
Dustin Oprea 7fb09bbf9f value_context.go: `ValueContext` now wraps members in accessors
It also embeds the type and byte-order so the VC can materialize/process
values self-sufficiently.
2019-12-29 00:35:35 -05:00
Dustin Oprea a69c3987eb type.go: Created `TagTypePrimitive` alias for `uint16`
Added a `Size()` method to it and decommissioned redundant
`TagTypeSize()` and `(TagType).Size()`.

- ifd_enumerate.go: Moved `ValueContext` definition to
  value_context.go .
2019-12-29 00:03:58 -05:00
Dustin Oprea 483dbacf14 type.go: Bugfix for math with embedded data. Add Format().
- ifd_builder.go
  - `BuilderTag` now embeds `ByteOrder`.
  - `BuilderTag` `String()` now prints value.

- type.go
  - `TagType` `ValueIsEmbedded()` renamed to `valueIsEmbedded()`.
  - Add `readRawEncoded()` method to `TagType`.
  - Add `Format()` method to `TagType` to isolate code for processing
    output strings for all types.
    - This will also print a suffixing ellipsis when `justFirst` is
      `true`.

  - Important bugfix for embedded values always being presented as
    four-bytes rather than being truncated to their reported unit-count
    bytes first. We tripped over this when some of our corresponding
    math was found to be wrong elsewhere.

- Minor reformatting.
2019-12-28 23:35:32 -05:00
Dustin Oprea 3dda8c2115 MakerNotes now print size and SHA1
- tags_unknown.go: Unhandled unknown values are now wrapped in a
  TagUnknownType_UnknownValue rather than returning an error. This is
  now used to print byte-counts and SHA1s for unhandled values.

- tags_unknown.go: UnparseableUnknownTagValuePlaceholder now has message
  "!UNKNOWN" rather than "!UNPARSEABLE".
2019-11-02 04:23:58 -04:00
Keith Woelke 12b8993a44 Change Ifd.GpsInfo() to calculate Degrees, Mintutes, and Seconds as float64 instead of int 2019-06-24 06:34:42 -04:00
Dustin Oprea 5b56a02e0a ifd_enumerate.go: Re-enable 2.3.0.0 support 2019-04-05 03:17:39 -04:00
Dustin Oprea 1578ce09d3 ifd_enumerate.go: Any missing functional GPS info returns no-GPS 2019-04-05 02:46:24 -04:00
Dustin Oprea 4ff0938c41 ifd_enumerate.go: Allow GPS version to not exist
- Also, log when we're not processing GPS due to incompatible version.
2019-04-02 11:48:48 -04:00
Dustin Oprea 38a16c885e ifd_builder.go: Add NextIb() so can access sibling IBs 2019-02-26 12:23:16 -05:00
Dustin Oprea eb7eb2b610 ifd_enumerate.go: Skip tags with invalid types.
Fixes #4.
2019-01-03 19:20:55 -05:00
Dustin Oprea ab09051aaa ifd_enumerate: Bugfix for incorrect read semantics.
- ...to make sure we get the right number of bytes.
2018-09-16 03:42:48 -04:00
Dustin Oprea 9068786204 Rewired to use IFD-path strings instead of IfdIdentities.
- These are absolute representations of where an IFD is positioned with
  respect to the other IFDs. There is a more-specific, "fully-qualified"
  form of the IFD-path that allows you to express indices in order to
  refer to specific siblings.

- Eliminates issues with IFDs at different levels potentially having the
  same name (if that's what is required with a certain dataset/
  datasource).

- There is a specific IFD registry that controls the heirarchy of IFDs
  that we recognize and the tags associated with the child IFDs. This
  allows custom hierarchies replacing even the TIFF specification for
  which are expected in an image (so we can read other types of images
  or any potential IFD hierarchy, even non-image ones).

- IFD and IB instances embed the IFD-path and FQ IFD-path that they were
  found or built for.
2018-08-01 08:35:21 -04:00
Dustin Oprea d3b45fae77 We now have to pass a specific tag-index in from the top.
- This will allow us to handle custom tags and, with a little more work,
  custom IFDs.
2018-07-26 22:45:43 -04:00
Dustin Oprea 86422559be ifd: Added recursive tag enumerator.
- We now embed a child-IFD index on the `Ifd`.
2018-06-14 03:52:12 -04:00
Dustin Oprea 235b1a5936 exif: Renamed ErrNotExif to ErrNoExif. 2018-06-13 05:51:28 -04:00
Dustin Oprea 7e10e5db27 ifd_builder: Added ChildWithIfdIdentity().
- Adjusted some of the tag replacement functionality.
2018-06-10 18:45:38 -04:00
Dustin Oprea 9b70a9180c ifd_enumerate: Added FindIfdFromRootIfd(). 2018-06-10 00:13:00 -04:00
Dustin Oprea 57f66ab0db ifd_enumerate: Renamed GPS image. 2018-06-09 03:20:17 -04:00
Dustin Oprea b9537b58c2 ifd_enumerate: Now parse the GPS info.
- Moved some IFD functionality out to its own file.
- Tweaked the permissions on some assets.
2018-06-09 02:11:24 -04:00
Dustin Oprea 1ce5b771db ifd_enumerate: Can now elect to not resolve tag value.
- To support testing.
2018-06-08 00:41:28 -04:00
Dustin Oprea 4c3a9d79f1 ifd_enumerate: Properly handle unknown-type tags during the initial parse. 2018-06-07 23:18:36 -04:00
Dustin Oprea cda05ba702 ifd_enumerate: Now extract and store value bytes immediately. 2018-06-07 22:51:40 -04:00
Dustin Oprea 4cd9e35801 ifd_enumerate: Implemented (*Ifd).ChildWithName() .
- Corrected some tabs that weren't correctly changed to spaces.
2018-06-07 21:36:14 -04:00
Dustin Oprea f4db9f31af tags: We now use a singleton TagIndex internally.
- We now embed the tags data so that we can be used in single,
  distributable binaries..
2018-06-07 05:15:51 -04:00
Dustin Oprea 7745cfe74c exif: Deimplemented IsExif().
- exif
  - Began deconstructing Exif type in favor of just defining those
    methods as functions.
  - Added additional tests.
2018-06-06 04:37:43 -04:00
Dustin Oprea b7368b1fb4 ifd_enumerate: Implemented ChildWithIfdIdentity. 2018-05-29 03:45:09 -04:00
Dustin Oprea 3c1c668a9f encode: We now encode child IFDs as they occur.
- ..rather than after the normal tags.
2018-05-28 20:04:02 -04:00
Dustin Oprea 75ff008365 thumbnails: Reimplemented to use normal decode flow.
- We added a trick to overcome the fact that the tag is a slice of longs
  rather than bytes (and would usually cause check errors and alignment
  problems), but this allows us to use the normal allocation and
  decoding flows that are used by normal tags.
  - Made things simpler, but we're still mis-encoding the
    thumbnail, somehow/somewhere.
2018-05-25 21:12:24 -04:00
Dustin Oprea c93f37a85d ifd_enumerate: Now parse and expose thumbnail. 2018-05-24 15:27:45 -04:00
Dustin Oprea d7ff9ccbbe Tag dumps now include indices. 2018-05-24 03:19:46 -04:00
Dustin Oprea 843976865e ifdBuilder.dumpToStrings: Fixed usage of II.
- We were ambiguously treating it as both the parent II in some places
  and the child II in others. It's supposed to be the parent II.
2018-05-24 01:58:58 -04:00
Dustin Oprea 3cee9b956b ifd_builder_encoder: Fixed subtle but detrimental bugs.
- ifd_builder_encode
  - Bugfix: We were assigning the "next" IFD in correctly (so, chaining
    was broken).
  - Bugfix: We weren't using the right value when *writing* the "next"
    IFD offset (so, chaining was, again, broken).
    - The same IFD was showing as both a child and a sibling, so we were
      seeing the EXIF IFD also being chained-to by the first root IFD
      instead of the *actual* sibling, but only after encoding and then
      decoding (so, this had to be tracked down in the encoding
      semantics, which was non-trivial).

  - Added a test for the stuff that we fixed.
  - Implemented journaling, where we can dump a hierarchically-formatted
    list of operations involved in a completed encode.

- ifd_enumerate: Added (Ifd).TagValueBytes() to return the raw tag-
  value's bytes (rather than just having (Ifd).TagValue(), which returns
  the value marshaled into a string). Good for comparing raw encoded
  and decoded values without imposing interpretation (which gets us into
  trouble with unknown-type tags whose values are non-standard and
  undocumentedand, therefore, not actually parseable).

- Rewired a lot of print and dump functions.
  - For naming-specificity as well as functionality.

- Removed from debugging.
2018-05-21 13:14:42 -04:00
Dustin Oprea cf17cf4aa6 ifd: Can now resolve its own tags' values.
- Adjustments to argument naming.
2018-05-06 16:19:20 -04:00
Dustin Oprea 887842e85a ifd_enumerate: Improved `DumpTree()`. 2018-05-05 01:58:00 -04:00
Dustin Oprea a3f14b2e42 ifd_builder_encode: Extended test to allocate multiple child IFDs.
- Want to be sure that the arithmetic to bump the offsets works.
2018-05-05 00:28:28 -04:00
Dustin Oprea 75b2c75c5a ifd_builder_encode: Added tests for encoding child IBs to EXIF.
- Big step. This is the most complicated thing we can do.
- ifd_builder_encode: Need to debug encoding linked IFDs to EXIF.
- ifd_builder: Renamed `SetNextIfd()` to `SetNextIb()`.
- ifd_builder: Bugfix to size assertion on return of
  (IfdBuilderEncode).encodeIfdToBytes().
- ifd_enumerate: Rename PrintNode() to PrintTree().
- ifd_enumerate: Added DumpTree() (to return a list of strings).
2018-05-03 12:43:06 -04:00
Dustin Oprea b75f980bc4 ifd_enumerate: Create II when `Ifd` is constructed.
- ..rather than on-the-fly. Now efficient, especially now that it's used
  for find operations.
2018-05-03 11:13:34 -04:00
Dustin Oprea 8c09d04212 ifd_enumerate: Added find-by-id and find-by-name to tags in `ifd`.
- Made `(Ifd).Entries` a slice of pointers ([]*IfdTagEntry).
2018-05-03 04:09:06 -04:00
Dustin Oprea 88cb7331cf documentation: Added examples.
- Renamed DefaultEncodeByteOrder to EncodeDefaultByteOrder.
2018-05-01 10:57:55 -04:00
Dustin Oprea 18d527eb72 ifd_builder_encode: Added tests for child-IFD encoding and allocation.
- ifd_enumerate: Added utility functions to parse individual, encoded
  IFDs and tags.
- ifd_builder: Corrected `NewBuilderTagFromConfig()` to automatically
  encode whichever type of value-argument it gets.
2018-04-28 19:22:13 -04:00
Dustin Oprea 9db558a82d ifd_enumerate: Moved tag-parsing to separate method. 2018-04-28 13:08:15 -04:00
Dustin Oprea d06a3c8963 ifd_builder: Implemented NewBuilderTagFromConfig() BT factory for testing.
- Updated IfdByteEncoder tests to use it instead of hacking-together
  their own BT's (makes for more standardized, consistent testing).

- Universally refactored all core IFD knowledge implemented upon a
  single IFD name to instead work with IfdIdentity instances, instead,
  in order to validate that we only recognize the IFDs only in the
  context of the correct parents in the hierarchy.

- Implemented standard testing byte-order (assigned to
  TestDefaultByteOrder).
2018-04-27 03:42:59 -04:00
Dustin Oprea 4bea09dc78 ifd_builder: Can now build a complete chain from existing EXIF.
- ifd_builder:
  - We now validate that `builderTag` instances are either a byte array
    or a child Ifd before allowing to add.
  - Renamed `builderTag.valueBytes` to `builderTag.value` (it's not
    necessarily bytes).
  - `builderTag` now gets the child IFD name if representing a child
    IFD.
  - Added ability to dump structure to string slice.
  - Added NewIfdBuilderFromExistingChain to reconstruct whole chain
    from a read IFD chain (collection).
  - Wrote IB dumper.
  - Added structural tests.
  - Moved ifd_tag_entry types to separate file.

- tags_unknown: Unknown-type tags can now satisfy the `UnknownTagValue`
interface to return `[]byte`.
  - `IfdTagEntry.ValueBytes` automatically uses this. Else, error if not
    `[]byte` or `string`.

- ifd_enumerate
  - Now embed `ByteOrder` in `Ifd` (we otherwise require it to be passed
    a bit too often).

- Renamed some occurences of "IFD" to "IB" where an actual IB in order
  to not be confusing.
2018-04-23 04:53:51 -04:00