Page 1 of 1

How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS information) ?

Posted: 2018-01-13T13:12:27-07:00
by PleskQuestion
Hi,

I’m in the process of developing a photo sharing platform, and wondering, when uploading the photo from a smart phone to the platform, if I can use the exif data(GPS information) of the photo systematically (by using ImageMagick) to extract the actual town/city name of the place that’s taken as the photo in order to display the town/city name in the platform. If it is possible, could you please explain to me the process of doing it?

Re: How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS informatio

Posted: 2018-01-13T13:20:39-07:00
by fmw42
Does your image have GMP location by city? Mostly I know that it has latitude and longitude. City may be there and if so, IM can extract it.

The IPTC meta data usually has the City and State. IM can extract that if it exists in your file.

Post your image to some free hosting service that will not change any data (such as dropbox.com) and put the URL here so we can download the image and see what EXIF data you have.

For example:

Code: Select all

convert DSCF6780.jpg -format "%[IPTC:2:90:City]" info:
Senoia

See https://www.imagemagick.org/script/escape.php

Re: How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS informatio

Posted: 2018-01-16T06:12:10-07:00
by PleskQuestion
fmw42,

Thanks for your reply.

This is the image to test to see whether or not I can extract the city name from the latitude and longtitue.

http://metown.info/upload/save_image/P4122246.JPG

By the way, would it be possible for me to set the batch processing for this city name extraction from the exif data ever time I upload the image to the system?

Re: How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS informatio

Posted: 2018-01-16T10:13:48-07:00
by fmw42
Your image has no EXIF (or GPS) meta data containing the city. I do not think GPS reports city, only latitude/longitude. It also does not use IPTC Meta data. The IPTC data is the one that contains city information. So you would need to save IPTC from your camera. I am not a photographer, so I cannot tell you how.

Here is the verbose information from your image.

Code: Select all

identify -verbose P4122246.JPG
Image: P4122246.JPG
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 4608x3456+0+0
  Resolution: 350x350
  Print size: 13.1657x9.87429
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: TrueColor
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 15925248
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 125.96 (0.49396)
      standard deviation: 64.2181 (0.251835)
      kurtosis: -0.977789
      skewness: 0.0819244
      entropy: 0.967361
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 119.409 (0.468272)
      standard deviation: 63.5411 (0.249181)
      kurtosis: -0.704159
      skewness: 0.409562
      entropy: 0.953446
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 96.2892 (0.377605)
      standard deviation: 72.378 (0.283835)
      kurtosis: -0.302746
      skewness: 1.05654
      entropy: 0.912694
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 113.886 (0.446612)
      standard deviation: 66.7124 (0.261617)
      kurtosis: -0.896386
      skewness: 0.490693
      entropy: 0.9445
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 4608x3456+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 88
  Orientation: TopLeft
  Properties:
    date:create: 2018-01-16T09:09:36-08:00
    date:modify: 2018-01-16T09:08:39-08:00
    exif:Artist: 
    exif:ColorSpace: 1
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:Contrast: 0
    exif:Copyright: 
    exif:CustomRendered: 0
    exif:DateTime: 2017:04:12 16:31:59
    exif:DateTimeDigitized: 2017:04:12 16:31:59
    exif:DateTimeOriginal: 2017:04:12 16:31:59
    exif:DigitalZoomRatio: 100/100
    exif:ExifImageLength: 3456
    exif:ExifImageWidth: 4608
    exif:ExifOffset: 218
    exif:ExifVersion: 48, 50, 51, 48
    exif:ExposureBiasValue: 0/10
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/160
    exif:FileSource: 3
    exif:Flash: 24
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:FNumber: 63/10
    exif:FocalLength: 17/1
    exif:GainControl: 1
    exif:ImageDescription: OLYMPUS DIGITAL CAMERA         
    exif:InteroperabilityOffset: 722
    exif:ISOSpeedRatings: 200
    exif:LightSource: 0
    exif:Make: OLYMPUS IMAGING CORP.  
    exif:MakerNote: 79, 76, 89, 77, 80, 85, 83, 0, 73, 73, 3, 0, 7, 0, 0, 2, 4, 0, 3, 0, 0, 0, 196, 13, 0, 0, 9, 2, 7, 0, 32, 0, 0, 0, 208, 13, 0, 0, 16, 32, 13, 0, 1, 0, 0, 0, 102, 0, 0, 0, 32, 32, 13, 0, 1, 0, 0, 0, 152, 1, 0, 0, 48, 32, 13, 0, 1, 0, 0, 0, 158, 4, 0, 0, 64, 32, 13, 0, 1, 0, 0, 0, 76, 5, 0, 0, 80, 32, 13, 0, 1, 0, 0, 0, 174, 9, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 7, 0, 4, 0, 0, 0, 48, 49, 48, 48, 0, 1, 2, 0, 6, 0, 0, 0, 244, 13, 0, 0, 1, 1, 2, 0, 32, 0, 0, 0, 250, 13, 0, 0, 2, 1, 2, 0, 32, 0, 0, 0, 26, 14, 0, 0, 3, 1, 5, 0, 1, 0, 0, 0, 60, 14, 0, 0, 4, 1, 4, 0, 1, 0, 0, 0, 2, 16, 0, 0, 1, 2, 1, 0, 6, 0, 0, 0, 78, 14, 0, 0, 2, 2, 2, 0, 32, 0, 0, 0, 84, 14, 0, 0, 3, 2, 2, 0, 32, 0, 0, 0, 116, 14, 0, 0, 4, 2, 4, 0, 1, 0, 0, 0, 1, 17, 0, 0, 5, 2, 3, 0, 1, 0, 0, 0, 0, 4, 0, 0, 6, 2, 3, 0, 1, 0, 0, 0, 249, 4, 0, 0, 7, 2, 3, 0, 1, 0, 0,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 0, 7, 1, 8, 0, 3, 0, 0, 0, 144
    exif:MaxApertureValue: 1024/256
    exif:MeteringMode: 5
    exif:Model: E-PL6           
    exif:Orientation: 1
    exif:PrintImageMatching: 80, 114, 105, 110, 116, 73, 77, 0, 48, 51, 48, 48, 0, 0, 37, 0, 1, 0, 20, 0, 20, 0, 2, 0, 1, 0, 0, 0, 3, 0, 240, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 11, 0, 56, 1, 0, 0, 12, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 14, 0, 80, 1, 0, 0, 16, 0, 96, 1, 0, 0, 32, 0, 180, 1, 0, 0, 0, 1, 3, 0, 0, 0, 1, 1, 255, 0, 0, 0, 2, 1, 131, 0, 0, 0, 3, 1, 131, 0, 0, 0, 4, 1, 131, 0, 0, 0, 5, 1, 131, 0, 0, 0, 6, 1, 131, 0, 0, 0, 7, 1, 128, 128, 128, 0, 16, 1, 129, 0, 0, 0, 0, 2, 0, 0, 0, 0, 7, 2, 0, 0, 0, 0, 8, 2, 0, 0, 0, 0, 9, 2, 0, 0, 0, 0, 10, 2, 0, 0, 0, 0, 11, 2, 248, 1, 0, 0, 13, 2, 0, 0, 0, 0, 32, 2, 214, 1, 0, 0, 0, 3, 3, 0, 0, 0, 1, 3, 255, 0, 0, 0, 2, 3, 131, 0, 0, 0, 3, 3, 131, 0, 0, 0, 6, 3, 131, 0, 0, 0, 16, 3, 129, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 9, 17, 0, 0, 16, 39, 0, 0, 11, 15, 0, 0, 16, 39, 0, 0, 151, 5, 0, 0, 16, 39, 0, 0, 176, 8, 0, 0, 16, 39, 0, 0, 1, 28, 0, 0, 16, 39, 0, 0, 94, 2, 0, 0, 16, 39, 0, 0, 139, 0, 0, 0, 16, 39, 0, 0, 203, 3, 0, 0, 16, 39, 0, 0, 229, 27, 0, 0, 16, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 64, 64, 128, 128, 192, 192, 255, 255, 0, 0, 64, 64, 128, 128, 192, 192, 255, 255, 0, 0, 64, 64, 128, 128, 192, 192, 255, 255, 5, 5, 5, 0, 0, 0, 64, 64, 128, 128, 192, 192, 255, 255, 0, 0, 64, 64, 128, 128, 192, 192, 255, 255, 0, 0, 64, 64, 128, 128, 192, 192, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:Sharpness: 0
    exif:Software: Version 1.0                    
    exif:thumbnail:Compression: 6
    exif:thumbnail:InteroperabilityIndex: R98
    exif:thumbnail:InteroperabilityVersion: 48, 49, 48, 48
    exif:thumbnail:JPEGInterchangeFormat: 14676
    exif:thumbnail:JPEGInterchangeFormatLength: 6280
    exif:thumbnail:ResolutionUnit: 2
    exif:thumbnail:XResolution: 72/1
    exif:thumbnail:YResolution: 72/1
    exif:UserComment: 0, 0, 0, 0, 0, 0, 0, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
    exif:WhiteBalance: 0
    exif:XResolution: 350/1
    exif:YCbCrPositioning: 2
    exif:YResolution: 350/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x1,1x1,1x1
    signature: e6d828747cde552ea05f7cf803ae7070fe166ac331ea9fb46214c4200176b90b
    unknown: 1
  Profiles:
    Profile-exif: 41980 bytes
  Artifacts:
    filename: P4122246.JPG
    verbose: true
  Tainted: False
  Filesize: 3.34467MiB
  Number pixels: 15.9252M
  Pixels per second: 54.9147MB
  User time: 0.280u
  Elapsed time: 0:01.289
  Version: ImageMagick 6.9.9-33 Q16 x86_64 2018-01-07 http://www.imagemagick.org
Fredericks-Mac-mini:desktop fred$ 
 
If you can enable that, then you would have to write a script for your server OS, to look for new files and then use the command I provided before to extract the city.

Re: How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS informatio

Posted: 2018-01-16T10:43:46-07:00
by Bonzo
Even if you know the lat on long I can not see how you will be able to find the city. There are databases for cities online but these are points in the centre. You would need to add a tolerance; for example London has an area of 1,572 km² Paris has an area of 105.4 km² but has all the outlying areas that probably make it larger than London. What about when you are close to the edge of an area/city and there is another within the tolerance? The tolerance would need to be different for each city.

Re: How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS informatio

Posted: 2018-01-24T16:06:06-07:00
by PleskQuestion
fmw42, Bonzo

Thanks for your investigation, and I really appreciate it.

So, I understand that it’s not feasible to extract the exact name of city or town from the exif data of the image that are taken from smart phone. What about some distinct data of the smart phone itself so that I can trace who took the photo from the smart phone id number in case I need?

Re: How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS informatio

Posted: 2018-01-24T16:56:01-07:00
by fmw42
All I know is that the IPTC data in the cellphone contains the city information. See https://www.imagemagick.org/script/escape.php

Re: How feasible is it by using ImageMagick to extract the town/city name of the place from the exif data(GPS informatio

Posted: 2018-01-24T17:12:15-07:00
by snibgo
If the EXIF data of the image contains the city (or street or country or continent), IM can extract it.

But the data will be present only if something has put it there. GPS coordinates are just that: coordinates. To get a city, or street or whatever, from the coordinates, you need a gazeteer.