-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow writing XMP to JPEG files #65
base: main
Are you sure you want to change the base?
Conversation
Just wanted to say that I'm pumped to get this feature into the library, but I want to give it a proper review because it'll be the first time the library is writing data and therefore the first time the library could potentially destroy users' files. I'm really busy at the moment but hope to find some time for this soon. Thanks for your patience. |
Quick update. I've reworked the JPEG reading code to be more robust. It will allow better performance and safety for injecting/replacing XMP in JPEG files. Haven't pushed it yet as I want to do some more tidying and it's late here now. |
bea6106
to
706cb88
Compare
I just updated my branch with your latest changes & also some refactorings.
I had used In both reading & writing, could the differences in the end of the preamble lead to segments that are not recognized as XMP segments? (And thereby ignoring them in read, or adding a duplicate segment in write?) |
… minimize undesired effects on the underlying data stream
I finished a lot of refactoring to accomplish a few things:
For writing to a file, the original data is fragmented into a list of Finally I added a bunch of tests (& test data) that verify the correct behavior at multiple abstraction levels.
With these modifications, Xmp metadata can be written (inserted/replaced) into a Stream of Jpeg data like this: var metadata_objects = new object[] { xmpXdoc };
var updatedStream = ImageMetadataWriter.WriteMetadata(originalStream, metadata_objects); |
@drewnoakes any chance this can be picked up again? i'm willing to merge the conflicts and to follow up on any remarks you still have after review. |
@elangelo the barriers to merging this are 1) my free time to review and really think deeply about this major change to the library and 2) my reluctance to take on the risk and responsibility involved with writing metadata to files and potentially breaking people's data. The cost of bugs becomes much higher once we start writing data. That said, there's regular interest in doing so. If you're interested in helping with this PR, then reviewing the general approach and thinking through how other kinds of metadata may be written would be helpful. Thanks. |
Adds a Root property to XmpDirectory such that the XDocument can be accessed directly.
Load behavior is modified to set the Root property.
Writing is accomplished by substituting existing Xml in App1 segments with new Xml, or inserting it if not present in the first place.
See #23 for more information.