Skip to content
This repository was archived by the owner on Dec 28, 2021. It is now read-only.

Refactor a lot of library internals#10

Open
Ortham wants to merge 22 commits intoelvis-epx:masterfrom
Ortham:refactor
Open

Refactor a lot of library internals#10
Ortham wants to merge 22 commits intoelvis-epx:masterfrom
Ortham:refactor

Conversation

@Ortham
Copy link

@Ortham Ortham commented Jul 7, 2017

I was going to try adding limited write support for GPS tags to rexif for my own use, but found how it was implemented difficult to work with, so started to refactor the library internals to more easily accommodate write support, and add some tests.

However, since then I've noticed that kamadak/exif-rs does pretty much the same thing as rexif, but with an implementation that's neater than my own refactoring efforts, and it already has tests, so I've pretty much jumped ship. It would be great if the two of you could join forces, because it's a pretty small niche, and having one preferred pure-Rust EXIF parser would be great.

Either way I thought I'd make this PR in case you wanted to merge some or all of what I've done. I realise there's a lot of different bits to it, so if you like some but not others, I can split it up into smaller PRs.

Ortham added 22 commits July 7, 2017 17:25
It's not useful to clients as where the data is stored doesn't matter
once the image has been parsed, and just duplicates data.
It's not useful to store the offset vs. the actual data once the
metadata has been parsed, and just duplicates data if there is no
offset.
Don't allocate a different string for each and every entry, just return
a static string slice. Also fix postprocessing setting a few units to
value_more_readable, and unknown units being non-empty, both counter to
the documented behaviour.
Make it a function on IfdFormat, not IfdEntry.
They're 16-bit values, use literals that match.
Use the names as given in the 2.31 spec.
This allows ExifEntry to directly preserve any tag values that don't map
to ExifTag values, inching closer to obsoleting IfdEntry.
It's now obsolete, as all its data is duplicated in the other ExifEntry
fields.
There's no reason to discard it, and the semantics could be useful.
Make it a consuming method on IfdEntry, and make the logic a bit more
readable. It's also more efficient as it avoids cloning the value.
Instead of using -1 values to indicate there are no bounds.
It's a much cleaner API, and uses itertools to provide a robust join()
implementation.

There is one instance (rational_values()) where it's preferable to use
itertools directly, as the trait implementation can't be specialised for
Vec<URational> and mapping to Vec<f64> first is less efficient.
Use the identical strpass formatter instead.
There's probably a way to abstract out the remaining commonality, but I
can't think of it.
It's cleaner and more idomatic.
Reimplement tag_value_new() as TagValue::new(), and put ToCsv in its own
module.
@elvis-epx
Copy link
Owner

elvis-epx commented Jul 7, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments