155 Commits
Author SHA1 Message Date
z b9badae4c0 docs(brand): add hero banner 2026-06-28 20:08:29 -07:00
z df8cdb71c3 chore(brand): dynamic hero banner 2026-06-28 20:08:27 -07:00
Hanzo AI 67eda824aa rebrand: rename module github.com/seaweedfs/goexif -> github.com/hanzoai/goexif
- create go.mod (deleted upstream at v1.0.3) with module github.com/hanzoai/goexif, go 1.21
- rewrite all internal self-imports (exif/tiff/mknote/exifstat/tests/regen) to hanzoai path
- update README import-path/install references
- pure stdlib, zero external deps; go build/vet/test all pass
v1.0.4
2026-06-26 13:01:39 -07:00
Chris LuandGitHub ac7b45a439 Delete go.mod 2022-09-13 10:15:15 -07:00
Chris LuandGitHub fba3643864 Create go.mod 2022-09-13 10:14:05 -07:00
Chris LuandGitHub 2fb6e805c1 Delete go.mod
go: github.com/seaweedfs/goexif@v2.0.0: invalid version: module contains a go.mod file, so module path must match major version ("github.com/seaweedfs/goexif/v2")
2022-09-13 10:09:35 -07:00
Chris Lu 90f82adb0b update to seaweedfs 2020-04-12 15:57:36 -07:00
Robert Carlsen 9e8deecbdd Revert "Implement a lazy tiff loader (#60)"
This reverts commit de6e3de636.
2019-04-01 11:21:01 -06:00
Örjan PerssonandRobert Carlsen 76e3344f75 Regenerate regression tests in stable order 2019-03-18 11:10:57 -06:00
Steven SorokaandRobert Carlsen 839e318141 Fixes a panic that can be caused by bad input data (#49) 2019-03-18 10:56:10 -06:00
Thibault JametandRobert Carlsen de6e3de636 Implement a lazy tiff loader (#60)
* Add benchmark test

Here are the results ran locally on a SSD:

goos: darwin
goarch: amd64
pkg: github.com/rwcarlsen/goexif/tiff
BenchmarkDecode-8       Skip downloading existing raw file http://www.rawsamples.ch/raws/canon/RAW_CANON_EOS_5DS.CR2
     200          43701603 ns/op        268632324 B/op      8709 allocs/op
PASS
ok      github.com/rwcarlsen/goexif/tiff        10.294s

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>

* Implement a lazy loader

When using tiff files like raw files, the time required to load the
whole file is significant. We do not load the whole picture frame in-memory
in order to access EXIF values. We do not even need to load all
EXIF values when we need to access a single EXIF field.

To improve the tiff loading speed, opportustically read from the
source file when needed.

This is a significant change in the interface as it requires to pass a
ReaderAt instead of a Reader.

In order not to break backward compatibility, a LazyDecode function has
been implemented to keep the same interface for the Decode one,
including filling every Tag.

There are 2 places where the backward compatibility is broken:
- DecodeTag now requires a ReaderAt and the base offset of the tag
- In case of using an open file to feed the tiff decoder, the file needs
  to stay open during the whole life cycle of the tiff structure

Benchmark results (on SSD):

EXIF parsing

goos: darwin
goarch: amd64
pkg: github.com/rwcarlsen/goexif/exif
BenchmarkDecode-8                 200000             89622 ns/op          133531 B/op        236 allocs/op
BenchmarkDecodeRaw-8               30000            486907 ns/op          341765 B/op       8553 allocs/op
BenchmarkLazyDecode-8             200000             83383 ns/op           31659 B/op        151 allocs/op
BenchmarkLazyDecodeRaw-8          200000             81325 ns/op           25051 B/op        164 allocs/op
PASS
ok      github.com/rwcarlsen/goexif/exif        72.727s

Before update, the benchmark results for exif parsing were:

goos: darwin
goarch: amd64
pkg: github.com/rwcarlsen/goexif/exif
BenchmarkDecode-8         100000            170961 ns/op          342412 B/op        961 allocs/op
BenchmarkDecodeRaw-8         100         109398876 ns/op        750784550 B/op      9244 allocs/op
PASS
ok      github.com/rwcarlsen/goexif/exif        33.940s

TIFF decoding

goos: darwin
goarch: amd64
pkg: github.com/rwcarlsen/goexif/tiff
BenchmarkDecode-8                    300          46751365 ns/op        268452505 B/op       113 allocs/op
BenchmarkLazyDecode-8             300000             43886 ns/op           10645 B/op         82 allocs/op
PASS
ok      github.com/rwcarlsen/goexif/tiff        32.337s

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>

* Add test to verify that Decode loads tag values

Future commits will use lazy load for values.
For backward compatibility, Decode will keep loading all tag values.

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>

* Add a test to ensure exif.Raw contains a valid exif file

Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>

* tweaks
2019-03-18 10:53:50 -06:00
Robert Carlsen 9b9b2bf712 fix regression tests 2019-03-18 10:51:23 -06:00
Sebastian N. KaupeandRobert Carlsen 2a31389554 Add Windows-specific EXIF tags (#71)
* Add XPComment field

* Add missing XP Windows fields
2019-03-18 10:07:43 -06:00
Wayne Ashley BerryandRobert Carlsen b1fd11e07d Update README.md (#67)
Adds godoc badge.
2019-01-07 12:46:17 -07:00
mplandGitHub 8d986c0345 Merge pull request #58 from mpl/go1
tiff: ignore all trailing NULLs in case of misleading Count
2018-05-18 20:21:00 +02:00
mpl 1cf24c2c98 tiff: ignore all trailing NULLs in case of misleading Count
As it can apparently happen with some camera software
(https://user-images.githubusercontent.com/2621/39392188-71a66fc4-4a66-11e8-9e3b-694163efa643.jpg),
sometimes a tag bytes will not only have a bunch of trailing NULLs, but
the Count for the data in that tag will be wrongly set too. i.e. instead
of being set to the actual number of relevant bytes to read, it will
be set to the full number of bytes, trailing zeroes included.

As a consequence, the Tag.strVal returned would include these trailing
NULLs too, which would lead to bugs such as
https://github.com/perkeep/perkeep/issues/1127

This change therefore makes sure to remove all trailing NULLs from the
data, in the case of DTAscii at least.
2018-05-18 19:53:39 +02:00
Brad FitzpatrickandRobert Carlsen fb35d3c329 exif: add support for parsing raw EXIF blocks, not in TIFF/JPEG containers (#54)
I need this for a HEIF package I'm publishing soon, to get the EXIF
out of iOS *.heic images.

Updates perkeep/perkeep#969
2018-04-10 12:50:26 -06:00
AykeandRobert Carlsen 80915cb8a5 Parse TimeZone information and use it for Exif.DateTime() (#50) 2018-04-10 12:47:03 -06:00
Mathias FredrikssonandRobert Carlsen d4c99c2ae0 exif: Define all constants as FieldName (#53)
exif: Define all constants as FieldName

Previously only the first entry was defined as a FieldName, the rest
were regular strings.  Fix constant types in mknote and tiff packages correspondingly.
2018-04-10 12:41:09 -06:00
Robert CarlsenandGitHub 17202558c8 Update tip/donation address 2018-01-10 11:11:40 -07:00
Robert Carlsen 709fab3d19 rename sample iphone image to describe its unique lens data among samples 2015-05-20 08:06:47 -06:00
Andreas AndersenandRobert Carlsen 489cb61b87 Added support for LensMake and LensModel 2015-05-20 08:03:57 -06:00
Felix GellerandRobert Carlsen 29300d832f Adds explicit error value for short tag read and helper to identify error. 2015-05-20 07:37:05 -06:00
mpl dd375eae42 newAppSec: be safer against bogus data length
It can apparently happen (with at least one gimp .xcf file), that it has
all the same markers as in a jpeg, up until reading the 2 bytes that would
code for the data length.
Since the data length is supposed to include those 2 bytes, the code was
assuming that the value of data length would be always at least 3, and
slicing under that assumption. Which breaks when e.g. an .xcf file
encodes the value 1 on these 2 bytes.

Fixes #34
2015-05-08 02:01:21 +02:00
Robert Carlsen 07696a806c changed bitcoin tip address 2014-12-31 17:11:52 -06:00
Robert Carlsen 41dad3aa08 more careful handling of offsets and memory. fixes #20 and #30. Thanks @jbardin 2014-12-22 15:16:34 -06:00
mpl 9fb3b23c1a Merge pull request #28 from mpl/go1 2014-10-29 00:03:19 +01:00
mpl e2c31ecc21 Decode: better effort in case of failure
Context: https://code.google.com/p/camlistore/issues/detail?id=493
Short version: when decoding fails because of e.g a particular tiff tag,
some/most of the rest of the decoded information could still be used.

This change is two-fold:

1) it provides some helper functions to diagnose the error returned by
Decode, and help decide whether the returned decoded information can
stil be used.

2) because sub-IFDs are independent, if parsing one of them fails,
the error is recorded but parsing the others is still attempted.
2014-10-28 23:58:13 +01:00
James Bardin 079eb62a87 Add another corrupt image and test
- check for 0-length tag value
2014-10-28 12:08:00 -04:00
James Bardin 1121e4b512 Abort on 0-length tag value or recursive IFD
- Might be caused by an unknown DataType, or a Count of 0, but either
  way the tag is invalid
- Check for immediate recursion when decoding IFDs. The 0-length check
  above will prevent the obvious case, but it still could be possible to
  have a self-referencing directory. This doesn't check for indirect
  recursion. Maybe there should be a limit to the number of times
  DecodeDir can be called?
2014-10-28 12:07:56 -04:00
James Bardin 43665a71ae Add tests for bad exif tags
- Verify that we error out immediately when an exif tag Count is
  MaxUint32, which is likely invalid.
- Verify that we don't try to buffer more than the size of the image
  file if the tag has an extraordinarily large Count.
2014-10-27 16:50:14 -04:00
James Bardin 41d926745a Don't allocate buffers for huge tag offsets
- There seems to be a relatively common corrupt tag which has an offset
  of MaxUint32. This is probably not a valid offset, so return early
  before we allocate a slice this large.
- Read tag values into a bytes.Buffer. This will prevent allocating
  memory beyond the size of the image file in the event that a tag is
  invalid or corrupt.
- Fixes issue #20
2014-10-27 09:32:08 -04:00
Robert Carlsen eb2943811a update regression test generation to use go generate 2014-09-16 11:21:30 -05:00
Robert Carlsen b60cbd4a97 Add makernote parsing to example. Improved example generally. 2014-09-16 11:17:14 -05:00
Robert Carlsen 48af04a88d fixed parser-registering order bug and simplified. Expanded example more and made example_test.go file consistent with new readme example 2014-09-16 11:16:55 -05:00
Ari MakelaandRobert Carlsen 8045b6363b Added a comment 2014-09-16 11:10:32 -05:00
Ari MakelaandRobert Carlsen 61fb130097 Added mknote.RegisterParsers 2014-09-16 11:10:32 -05:00
Robert Carlsen 4dfd6493d6 make example compile 2014-09-16 11:01:50 -05:00
Robert Carlsen b07b953aa1 Add default funcs for geo-coordinate and date/time taken retrieval 2014-09-16 11:00:04 -05:00
Robert Carlsen decf27ae5f removed explicit panics in favor of error returns. 2014-09-15 18:08:49 -05:00
Fabian Wickborn b42a23f2d1 Merge branch 'nopanic' into camlistoreBackport
Conflicts:
	exif/regress_expected_test.go
2014-09-15 23:46:36 +02:00
Fabian Wickborn 75f72590cf Sync regression test cases with tiff.Tag.String()
Regression test case regeneration would lead to failing tests, as
produced string no longer matched expected string.
2014-09-15 23:37:03 +02:00
Fabian Wickborn a61c796c73 Merge branch 'nopanic' into camlistoreBackport
Required some changes wrt. to new API in exif.go
2014-09-15 22:45:20 +02:00
Fabian Wickborn 87066cfba7 Added test image for GPS coordinates encoded as string 2014-09-15 21:41:37 +02:00
Fabian Wickborn 8dfc0d1017 Improve time zone and Geo coordinate parsing
This is a merge with
camlistore.org/third_party/github.com/rwcarlsen/goexif

Squash of the following commits:

- exif: make DateTime return time.Local location when unknown timezone
  (https://camlistore.googlesource.com/camlistore/+/a82738064436e5010268616655650ac71855668f)
- exif: add Exif.LatLong accessor
  https://camlistore.googlesource.com/camlistore/+/b6d3d1a1037260b753b914e0c07279811cc76777
- Prevent panic crash due to malformed EXIF geotags
  (https://camlistore-review.googlesource.com/#/c/3637/5)
2014-09-15 21:23:33 +02:00
Robert Carlsen 362b247035 fix mknote StringVal call 2014-08-28 10:26:09 -05:00
Robert Carlsen 1335a39029 String output, err, and doc updates. Other tweaks.
* renamed TypeCategory to Format and made format calculated upon decoding
  rather than repeatedly for every format call

* unexport BadTypecastErr -> wrongFmtErr

* Change String method to just return the string value - and don't have
  square brackets if only a single value

* add separate Int and Int64 retrieval methods

* update docs
2014-08-28 10:22:21 -05:00
Robert Carlsen 86f1faec90 return errors instead of panicing 2014-08-27 15:29:44 -05:00
Robert Carlsen cf045e9d6b go fmt 2014-02-01 17:31:29 -06:00
Robert Carlsen c1db93abe3 created type+constants for raw tiff tag data types. parametrized sample test file dirs. minor tweaks. 2014-02-01 12:04:34 -06:00