Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Niche feature request: "Serializable" tag class? #11

Open
MartinKlefas opened this issue Feb 18, 2019 · 4 comments
Open

Niche feature request: "Serializable" tag class? #11

MartinKlefas opened this issue Feb 18, 2019 · 4 comments

Comments

@MartinKlefas
Copy link

I was hoping to read the tags out of a collection of images once, and save the information to a companion file to speed things up the next time I read the tags. When I try to do this with a JSON Serializer I get the below error:
System.Runtime.Serialization.InvalidDataContractException
HResult=0x80131500
Message=Type 'NExifTool.Tag' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types. Source=System.Runtime.Serialization

It's probably not that common an operation, so I understand if this isn't something you can fix. If it's something you can look into there's more information on the whole process here: https://www.newtonsoft.com/json/help/html/SerializingJSON.htm

@AerisG222
Copy link
Owner

I am not too crazy about the idea of adding the attributes for this. I think it would be a better approach to copy the exif data to your own class and then serialize how you wish.

With that said, depending on what you are trying to do, there might be ways to further expose exiftool functionality to achieve a similar result. There is an ability of exiftool to dump json (and other formats too) to files. For example, try running the following commands:

  1. dump exif data into one large json array for all images under a particular directory:
    exiftool -r -j image_directory > exifdata.json

  2. dump exif data in json format, such that a sidecar file is created for each image
    exiftool -r -j -w .json image_directory

If either the first or second option are useful to you to have in NExifTool, I would be happy to consider adding that to the library.

@MartinKlefas
Copy link
Author

I'd not considered that exiftool might have the function built in, I'll look into those options and let you know how it goes.
Thanks.

@MartinKlefas
Copy link
Author

I'm happy to report that the first option exiftool -r -j image_directory > exifdata.json works brilliantly.
The second option is also quite handy.

Having either as part of the library would be very helpful - as would the ability to then read the resulting JSON information into a Tag but I understand that that might be a lot of extra work.

@AerisG222
Copy link
Owner

Thanks for getting back to me, glad to hear that worked for you. I have a lot going on at the moment, but once I have some time I will take a look at adding this to the library. If you have interest in implementing such a feature, I'd be happy to accept a PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants