Created
August 27, 2014 18:30
-
-
Save phillip-haydon/d5d18517ec923b23e158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var exifStream = new MemoryStream()) | |
using (var imageFactory = new ImageFactory()) | |
{ | |
file.Value.Position = 0; | |
file.Value.CopyTo(exifStream); | |
exifStream.Position = 0; | |
var exifData = imageFactory.Load(exifStream) | |
.GetExifTags(); | |
foreach (var tag in exifData) | |
{ | |
photo.AddImageProperties(tag.Name, tag.Value, tag.RawValue); | |
} | |
} |
OH, I'm using NancyFX so am currently running this stuff when the file is uploaded.
So file happens to be the file uploaded, but I have to copy it into a MemoryStream to pass into ImageFactory.
Also I saved the raw file prior to this which is why i reset the stream. It's just fluff code.
So you want to be able to set value as well as get them? Right now I'm only focusing on getting the values out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So are
file
andphoto
both Image files? WouldAddImageProperties
be an extension to that type?ImageFactory maintains an image internally so you'd probably be better to spin up another instance of that and add the EXIF tags to that instance.
Something like
You could possibly simplify that also by using the
Load(string)
andSave(sting)
overloads