oozcitak / exiflibrary

A .Net Standard library for editing Exif metadata
MIT License
131 stars 48 forks source link

Cannot write longitude and latitude values #84

Open TriLogic opened 3 years ago

TriLogic commented 3 years ago

this produces a target file for which the longitude cannot be read

            string iname = @"Y:\issue-66.jpg";
            string oname = @"Y:\target.jpg";

            var file = ImageFile.FromFile(iname);

            var olat = file.Properties.Get<GPSLatitudeLongitude>(ExifTag.GPSLatitude);
            var olng = file.Properties.Get<GPSLatitudeLongitude>(ExifTag.GPSLongitude);

            var glat = new GPSLatitudeLongitude(ExifTag.GPSLongitude, olat.Value);
            var glng = new GPSLatitudeLongitude(ExifTag.GPSLongitude, olng.Value);

            file.Properties.Set(ExifTag.GPSLatitude, olat.ToFloat());
            file.Properties.Set(ExifTag.GPSLongitude, olng.ToFloat());
            file.Save(oname);
sschaub commented 3 years ago

I was able to write latitude/longitude values this way:

image.Properties.Set(ExifTag.GPSLatitude, 38f, 54f, 36f);
image.Properties.Set(ExifTag.GPSLatitudeRef, GPSLatitudeRef.North);
image.Properties.Set(ExifTag.GPSLongitude, 77f, 0f, 53f);
image.Properties.Set(ExifTag.GPSLongitudeRef, GPSLongitudeRef.West);
image.Properties.Set(ExifTag.GPSAltitude, 2f);
image.Properties.Set(ExifTag.GPSAltitudeRef, GPSAltitudeRef.AboveSeaLevel);

The latitude/longitude values are in degrees / minutes / seconds.