Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Reading/Writing EXIF data with JPGs

Discussion in 'Scripting' started by andyz, Nov 16, 2017.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,133
    Has anyone written/used code in Unity to read or write EXIF data for jpgs?
    I want to add exif data on saving a texture to jpg
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    There are some EXIF libraries for C# out there on the web. The first google search I found was for .NET 4.0 but since it is open source, perhaps you can get somewhere with it anyway, since JPEG is a pretty well-established standard with lots of different ways of getting at the data.
     
    Bunny83 likes this.
  3. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,133
    Yes many out there but most rely on System.Drawing dll which can be hacked into Unity, but not exactly cross platform.
    To write a specific jpg EXIF header I ended up making a byte array from a source jpg's header and rewriting the header on exported jpgs.
     
    TimeWalk-org likes this.
  4. TimeWalk-org

    TimeWalk-org

    Joined:
    Nov 3, 2014
    Posts:
    38
    Any examples of this we could reference? I've built a working Unity 2019-based project to READ the EXIF data (https://github.com/tedbarnett/read-exif-in-unity), but I can't find ANY Unity-friendly code online that would let me update a few of the fields (e.g. date, location) and write these back to the original JPG.
     
    Last edited: Dec 12, 2019
  5. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,133
    That was a long time ago I think I was just copying a preset data set to replace default EXIF data. I would look for more open source
     
  6. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40