Hi, just wondering if it is possible to use jpg image as "Data Container".
Here is how it should work:
The user defines a new Tag Name.
The user creates an object (whatever it represents) and serializes it to a string variable to define Tag Value.
Is it possible to write Tag to jpg file? Hopefully regardless of Tag Value length.
Sure, interpreting such jpeg would need ExifTool to extract relevant tag and external parsing and rendering function to make use of it.
Keep the fingers crossed :D
You can use a JPEG as a simple data container by simply adding a file to the end of the JPEG. On Mac/Linux it is simple:
cat FILE >> test.jpg
This can also be done with ExifTool:
exiftool "-trailer<=FILE" test.jpg
And to retrieve the file again:
exiftool -trailer -b test.jpg > OUTFILE
But note that you will lose the trailer if the jpg is edited by most other editors.
- Phil
Thanks, Phil, that looks just fine.
It is just a binary data append to a jpg file then (looking at jpg as a binary container).
I assume that ExifTool knows exactly where the genuine jpg binary structure ends in order to perform retrieval using exiftool -trailer -b test.jpg > OUTFILE
Content-rich jpg file will be set to read-only after creation because the job is done. Will be analyzed in dedicated software.
If there is a simple method of reliable en-of-trailer detection (without ExifTool) please let me know.
Tadej
Just one thing I should mention. You must be sure the jpg doesn't have a trailer to begin with.
I don't know of any easier way than ExifTool to extract JPEG trailers, but programming this isn't too difficult if you understand the JPEG structure.
- Phil
Hi Harvey, mentally merging my questions and your answers here is a simple, bulletproof solution on how to separate real jpg data (the trailer) from binary data appended at the end of the original jpg file.
Data to be appended should start with the binary representation of the following.
WHAT PHIL HAS DONE BY PROVIDING SUCH EXCELLENT WORK EMBODIED IN EXIFTOOL IS JUST AMAZING!!!
And ending with THANK YOU PHIL!!!
A simple analysis of a binary stream created from a file does all the magic needed.
I can assure you that there will never ever be a camera to produce a jpg file that would contain such representation of pixels.
Thanks for creating ExifTool :D
Tadej