Skip to content

Write EXIF DateTimeOriginal example, please #1235

Answered by JimBobSquarePants
GF-Huang asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @GF-Huang here's an example.

using (var image = new Image<Rgba32>(100, 100))
{
    // Create a new profile, since we crated the image.
    image.Metadata.ExifProfile = new ExifProfile();

    const string format = "yyyy:MM:dd HH:mm:ss";
    var now = DateTime.Now;
    var dt = now.ToString(format);

    // Set the metadata value.
    image.Metadata.ExifProfile.SetValue(ExifTag.DateTimeOriginal, dt);

    // Get the value.
    var dt2 = image.Metadata.ExifProfile.GetValue(ExifTag.DateTimeOriginal).Value;
    DateTime.TryParseExact(dt2, format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out DateTime now2);
}

https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Me…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@dlemstra
Comment options

@JimBobSquarePants
Comment options

@dlemstra
Comment options

@JimBobSquarePants
Comment options

Answer selected by GF-Huang
Comment options

You must be logged in to vote
1 reply
@GF-Huang
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants