开发者

How to embed metadata (i.e. JSON/XML) into an image file?

开发者 https://www.devze.com 2023-04-05 00:46 出处:网络
In .NET suppose I have an application that can create and open an image that has its metadata defined in a seperate file (i.e. \'.json\'/\'.xml\'). It would spit or open the metadata file of the same

In .NET suppose I have an application that can create and open an image that has its metadata defined in a seperate file (i.e. '.json'/'.xml'). It would spit or open the metadata file of the same name as the image file.

Now to make distribution of the image + metadata files easier, I want to eliminate the extra metadata file so that users can open an image and has all the relevent info about the image. What are some of the good strategies for embedding the data into the image file itself?

Here are a few possibilities I found by googling:

  • Visual embedding:
    • Data encoded as 2D Barcode such as QR Code, Data Matrix or PDF417.
    • Data drawn as plain text on the image, retrieved through OCR
  • Format embedding:
    • Data inserted as JPEG comments/EXIF comments
    • Data inserted as PNG text chunks

The basic req开发者_高级运维uirements are:

  • Data can be in JSON, XML or binary format, as long as it's machine-readable.
  • Data can be in the KB's, up to several dozens of KB's. The more the better.
  • For visual embedding:
    • Data should hold up well against a certain degree of lossy compressions.
    • The shape of the data 'zone' on the image's canvas should be as flexible as possible to better use the image's real estate.
  • Support all common image formats. (bmp, jpg, png, gif, etc.)
  • If possible, use open source .NET libraries.

Any advice welcomed. Thanks!


One way to do this is to store the information as a string of XML in the EXIF portion of the .jpg file, maybe in the UserComment field (9286H) of the EXIF IFD.

Here is some info on loading and saving metadata using gdi+.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号