c# - How to add GPS data to metadata on windows phone 8.1 RT -
i making camera app in c# windows phone 8.1 rt , want add gps location metadata of taken picture.
reading location data gps not problem. reading metadata (in case) image.jpg not problem. writing/editing data is, because fields readonly.
take picture, saving:
public async void take_picture() { imageencodingproperties format = imageencodingproperties.createjpeg(); format.width = resolutionwidth; format.height = resolutionheight; var imagestream = new inmemoryrandomaccessstream(); await capturemanager.capturephototostreamasync(format, imagestream); //some more code storagefile file = await knownfolders.pictureslibrary.createfileasync("nameofpicture.jpg", creationcollisionoption.generateuniquename); var filestream = await file.openasync(fileaccessmode.readwrite); await randomaccessstream.copyasync(imagestream, filestream); }
read metadata. (these properties empty, properties can read picture.)
private async void metaread_button_click(object sender, routedeventargs e) { storagefile file1 = await knownfolders.pictureslibrary.getfileasync("nameofpicture.jpg"); var fileprops = await file1.properties.getimagepropertiesasync(); textblock1.text = "manufacturer: " + fileprops.cameramanufacturer; //writable property textblock2.text = "model: " + fileprops.cameramodel; //writable property textblock3.text = "title: " + fileprops.title; //writable property textblock4.text = "latitude: " + fileprops.latitude; //readonly property textblock5.text = "longtitude: " + fileprops.longitude; //readonly property textblock6.text = "orientation: " + fileprops.orientation; //readonly property }
modify writable metadata:
private async void metawrite_button_click(object sender, routedeventargs e) { storagefile file2 = await knownfolders.pictureslibrary.getfileasync("nameofpicture.jpg"); var fileprops = await file2.properties.getimagepropertiesasync(); fileprops.title = "picture me"; await fileprops.savepropertiesasync(); }
question: how can readonly properties set? "imageencodingproperties" set properties of image, not file.
finally found answer one. see rd8388's answer. need convert lat/long degree/minute/second format. not need comment out longitude denominator suggested. make sure seconds (of numerator property) divided denominator falls within expected range.
Comments
Post a Comment