For example the Exif standard has a "User Comment" tag that has a limit of 256 characters I believe.
If I want to add lets say a story into metadata, what would be my best bet for several megabytes worth of text.
Basically I'm trying to store certain things inside of an image and have it not lost when transferred between iPhones. I wrote this image directly into the image before by converting it into NSData and开发者_如何学Go then appending the huge string and then changing the NSData to UIImage. This worked but when I emailed, texted, or placed it inside the photolibrary, all information I added was lost.
Apparently metadata stays with the image and I have it working using user comment but there is a character limit.
How would I go about using an existing tag or making my own so I can have almost no limit on the text size? I don't care how big the file gets.
I will assume you are talking about JPEG images because the file format is central to this question.
JPEG images have an inherent 64kB segment-size limit. The EXIF UserComment has no length limit, but EXIF is limited to a single JPEG segment, so it is restricted to 64kB.
Some metadata editors (like ExifTool) support multi-segment metadata types. Both XMP and JPEG comments may span multiple segments. I would suggest simply using the JPEG Comment because multi-segment support of XMP is probably not very common. If you choose XMP, something like the XMP-dc:Description tag may be suitable.
Have you looked into the IPTC extended data sets? They seem to allow what you want to do.
Or if the image is going directly between systems, you could simply append it to the end of the image data - for example, given a JPG lie I can do something like:
cat >> my image.jpg
write in some text, and it does not interfere with applications reading JPG.
Of course, if you need the transmitted information to last through several editings of the image, then EXIF (or IPTC) is the only way to store data.
精彩评论