ExifReader icon indicating copy to clipboard operation
ExifReader copied to clipboard

Get raw header/indices from file?

Open Pithikos opened this issue 4 years ago • 4 comments

Thanks for your library. It's very well made and the API is a beauty to use.

I just wonder if there is a way to inspect at what point the header was found. For example something like below:

ExifReader.load(e.target.result).then((metadata, headerStart, headerEnd) => {
    // Upload the header of the file..
})

The reason I need this, is because I need to send the raw header to the backend (in order to support various media file and not only JPG). At the moment I need to send 256KB of data regardless if the header is only in the first 512 bytes for example. This becomes a real issue when dealing with 100s of files.

Are there plans to support this? Or is it something that already exists?

Pithikos avatar Aug 07 '20 17:08 Pithikos

Hi! Thanks! :-) Is this the same request as this one? https://github.com/mattiasw/ExifReader/issues/116 In that case there is some discussion in that thread.

mattiasw avatar Aug 07 '20 19:08 mattiasw

Yep, seems similar so I close this one and I'll comment there :+1:

Pithikos avatar Aug 07 '20 20:08 Pithikos

Actually I had a look at that question but this is a bit simpler. In that the OP wants to add the header back to a new file.. which can be a bit complicated in case there are header segments all over the place.

In my case I merely want to know the position where we last saw a header segment. So if I read 256KB and find the last bit of header at 200KB then that would be it. In my case I don't try to put it back to a file.. I just need it to be stored in the backend separately from the file.

I think this is much simpler than in that issue since we just need to keep track of the index at the rigtmost position so far while parsing.

Pithikos avatar Aug 07 '20 22:08 Pithikos

Ah, okay, that does seem much simpler. And would make for interesting statistics too to know how large the metadata blocks usually are in practise. It would complicate the code though, I will have to think a bit more about this.

mattiasw avatar Aug 12 '20 14:08 mattiasw