Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. add gps info to image

add gps info to image

Scheduled Pinned Locked Moved C#
graphicshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    behzadcp
    wrote on last edited by
    #1

    hi guys i write gps info into image but not display whats problem private void button1_Click(object sender, EventArgs e) { Image Pic; PropertyItem[] PropertyItems; string FilenameTemp; System.Drawing.Imaging.Encoder Enc = System.Drawing.Imaging.Encoder.Transformation; EncoderParameters EncParms = new EncoderParameters(1); EncoderParameter EncParm; ImageCodecInfo CodecInfo = GetEncoderInfo("image/jpeg"); double dLat = 38.00000000000; double dLong = 48.0000000000; string Filename = "E:\\001.jpg"; byte[] bLat = BitConverter.GetBytes(dLat); byte[] bLong = BitConverter.GetBytes(dLong); Pic = Image.FromFile(Filename); PropertyItems = Pic.PropertyItems; PropertyItems[0].Id = 0x0002; PropertyItems[0].Type = 5; PropertyItems[0].Len = bLong.Length; PropertyItems[0].Value = bLong; Pic.SetPropertyItem(PropertyItems[0]); PropertyItems = Pic.PropertyItems; PropertyItems[0].Id = 0x0004; PropertyItems[0].Type = 5; PropertyItems[0].Len = bLat.Length; PropertyItems[0].Value = bLat; Pic.SetPropertyItem(PropertyItems[0]); FilenameTemp = Filename + ".temp"; EncParm = new EncoderParameter(Enc, (long)EncoderValue.TransformRotate90); EncParms.Param[0] = EncParm; Pic.Save("e:\\0001.jpg", CodecInfo, EncParms); } private static ImageCodecInfo GetEncoderInfo(String mimeType) { int j; ImageCodecInfo[] encoders; encoders = ImageCodecInfo.GetImageEncoders(); for (j = 0; j < encoders.Length; ++j) { if (encoders[j].MimeType == mimeType) return encoders[j]; } return null; } thanks a lot

    B 1 Reply Last reply
    0
    • B behzadcp

      hi guys i write gps info into image but not display whats problem private void button1_Click(object sender, EventArgs e) { Image Pic; PropertyItem[] PropertyItems; string FilenameTemp; System.Drawing.Imaging.Encoder Enc = System.Drawing.Imaging.Encoder.Transformation; EncoderParameters EncParms = new EncoderParameters(1); EncoderParameter EncParm; ImageCodecInfo CodecInfo = GetEncoderInfo("image/jpeg"); double dLat = 38.00000000000; double dLong = 48.0000000000; string Filename = "E:\\001.jpg"; byte[] bLat = BitConverter.GetBytes(dLat); byte[] bLong = BitConverter.GetBytes(dLong); Pic = Image.FromFile(Filename); PropertyItems = Pic.PropertyItems; PropertyItems[0].Id = 0x0002; PropertyItems[0].Type = 5; PropertyItems[0].Len = bLong.Length; PropertyItems[0].Value = bLong; Pic.SetPropertyItem(PropertyItems[0]); PropertyItems = Pic.PropertyItems; PropertyItems[0].Id = 0x0004; PropertyItems[0].Type = 5; PropertyItems[0].Len = bLat.Length; PropertyItems[0].Value = bLat; Pic.SetPropertyItem(PropertyItems[0]); FilenameTemp = Filename + ".temp"; EncParm = new EncoderParameter(Enc, (long)EncoderValue.TransformRotate90); EncParms.Param[0] = EncParm; Pic.Save("e:\\0001.jpg", CodecInfo, EncParms); } private static ImageCodecInfo GetEncoderInfo(String mimeType) { int j; ImageCodecInfo[] encoders; encoders = ImageCodecInfo.GetImageEncoders(); for (j = 0; j < encoders.Length; ++j) { if (encoders[j].MimeType == mimeType) return encoders[j]; } return null; } thanks a lot

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      There is an article on an Exif library here on CodeProject: ExifLibrary for .NET[^] Perhaps that might help you - I had to change some code for updating GPS values, but according to the author that should already be fixed now.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups