# Is there a package to read EXIF data from a jpg image?

**URL:** <https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297>\
**Category:** Specific Domains\
**Tags:** images\
**Created:** [February 28, 2020, 6:43pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297 "2020-02-28T18:43:10Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [February 28, 2020, 6:43pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/1 "2020-02-28T18:43:10Z")

</div>

I’m looking for a package to read EXIF data from a jpg image. I had hoped that ImageMetadata would do that, but but when I load a jpg image, all the metadata is gone, e.g.,  
img=load(“/Users/prange/Downloads/TKNE8480.JPG”)  
3024×4032 Array{RGBX{N0f8},2} with eltype RGBX{Normed{UInt8,8}}  
What is the preferred way to extract this information? In particular, I’m trying to extract the GPS coordinates.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [February 28, 2020, 10:31pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/2 "2020-02-28T22:31:14Z")

</div>

ImageMagick.jl has some undocumented functions `getimageproperty` and `getimageproperties`. Let us know if those help.

---

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [February 29, 2020, 2:21am UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/3 "2020-02-29T02:21:51Z")

</div>

ImageMagick contains a function magickinfo() that reads the EXIF info from an image file without loading the image. This is fast and provides just what I need. Thanks.

---

<div class="post-metadata">

**Author:** ![YohanSassi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yohansassi/32/20583_2.png) [@YohanSassi](https://discourse.julialang.org/u/YohanSassi)\
**Post date:** [March 3, 2021, 12:47pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/4 "2021-03-03T12:47:14Z")

</div>

@michael-prange I’m trying to extract some information from JPG, especially date and time the picture was taken, for that I’m using the ImageMagick.magickinfo() function as follow:

```julia
dir = "/Users/yohan/Documents/julia-programming/sbs_dist.jl/pic"
info = ImageMagick.magickinfo(joinpath(dir,"CT020072.JPG"))
show(info)

```

and here is the output:

```julia
["date:create", "date:modify", "exif:ApertureValue", "exif:ColorSpace", "exif:ComponentsConfiguration", "exif:CustomRendered", "exif:DateTime", "exif:DateTimeDigitized", "exif:DateTimeOriginal", "exif:ExifImageLength", "exif:ExifImageWidth", "exif:ExifOffset", "exif:ExifVersion", "exif:ExposureBiasValue", "exif:ExposureMode", "exif:ExposureProgram", "exif:ExposureTime", "exif:FileSource", "exif:FlashPixVersion", "exif:FNumber", "exif:FocalLength", "exif:GainControl", "exif:ImageDescription", "exif:InteroperabilityOffset", "exif:ISOSpeedRatings", "exif:LightSource", "exif:Make", "exif:MakerNote", "exif:MaxApertureValue", "exif:MeteringMode", "exif:Model", "exif:Orientation", "exif:ResolutionUnit", "exif:SceneCaptureType", "exif:ShutterSpeedValue", "exif:Software", "exif:thumbnail:Compression", "exif:thumbnail:InteroperabilityIndex", "exif:thumbnail:InteroperabilityVersion", "exif:thumbnail:JPEGInterchangeFormat", "exif:thumbnail:JPEGInterchangeFormatLength", "exif:thumbnail:ResolutionUnit", "exif:thumbnail:XResolution", "exif:thumbnail:YResolution", "exif:WhiteBalance", "exif:XResolution", "exif:YCbCrPositioning", "exif:YResolution", "jpeg:colorspace", "jpeg:sampling-factor", "unknown"]

```

As there are not documentation about this function, I would like to know how I can extract the date and time from the data of the JPG picture. Here in the results are only given strings but not really the information I need. Thanks in advance for the time you will take to help me.

---

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [March 3, 2021, 2:03pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/5 "2021-03-03T14:03:29Z")

</div>

Yohan,

Here is how I extracted some image information. I hope this helps. Note that the coordinates are given as ratios for degrees, minutes and seconds. You just need to do the division yourself.

Michael

> magickinfo(“IMG\_6477.jpeg”,  
> (“exif:GPSLatitude”,“exif:GPSLatitudeRef”,  
> “exif:GPSLongitude”,“exif:GPSLongitudeRef”,  
> “exif:GPSAltitude”))

```julia
Dict{String,Any} with 5 entries:
  "exif:GPSLongitudeRef" => "W"
  "exif:GPSLatitude" => "44/1, 22/1, 2326/100"
  "exif:GPSLatitudeRef" => "N"
  "exif:GPSLongitude" => "71/1, 13/1, 5301/100"
  "exif:GPSAltitude" => "261189/757"

```

---

<div class="post-metadata">

**Author:** ![YohanSassi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yohansassi/32/20583_2.png) [@YohanSassi](https://discourse.julialang.org/u/YohanSassi)\
**Post date:** [March 3, 2021, 2:14pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/6 "2021-03-03T14:14:19Z")

</div>

@michael-prange, Thank you very much it’s working, what was missing only is to specify in the function the information I wanted to extract (a beginner’s mistake). I didn’t understood that the strings I had was actually the list of all information I can extract and in which I had to select the one I was interested by. So I have now:

```julia
ImageMagick.magickinfo("CT020072.JPG",( "exif:DateTime"))

Dict{String,Any} with 1 entries:
  "exif:DateTime" => "2020:12:07 09:22:04"

```

Which is exactly what I was looking for ! Thanks !

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 3, 2021, 3:16pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/7 "2021-03-03T15:16:48Z")

</div>

Would love it if someone would click [Sign in to GitHub · GitHub](https://github.com/login?return_to=%2FJuliaIO%2FImageMagick.jl%2Fblob%2F284f6c6dd453517103c5ac2ec0d481425ddda949%2Fsrc%2FImageMagick.jl)

and edit the file to add a docstring! (Click the pencil icon)

---

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [March 3, 2021, 3:38pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/8 "2021-03-03T15:38:53Z")

</div>

Tim,

I will take a stab at it. Not sure how complete my documentation will be, but anything is better than nothing.

Michael

---

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [March 3, 2021, 6:33pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/9 "2021-03-03T18:33:10Z")

</div>

Tim,

When I moused over the pencil icon it says that I "must be on a branch to make or propose changes to this file.” I’m still a newbie with GitHub. Does this mean that I should make a fork, or is it a PR that I need to do? I had assumed that I could just edit the file in the browser from your link.

Michael

---

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [March 3, 2021, 6:56pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/10 "2021-03-03T18:56:04Z")

</div>

Tim,

Here are my proposed changes:

@doc raw"“”  
magickinfo(file::Union{AbstractString,IO})

Reads an image `file` and returns an array of strings describing the property data in the image file.

# Examples

```julia-repl
> p = magickinfo("Image.jpeg")
63-element Array{String,1}:
"date:create"
"date:modify"
"exif:ApertureValue"
"exif:BrightnessValue"
"exif:ColorSpace"
"exif:ComponentsConfiguration""exif:DateTime"
"exif:DateTimeDigitized"
"exif:DateTimeOriginal"
"exif:ExifImageLength"
"exif:ExifImageWidth"
"exif:ExifOffset"
"exif:ExifVersion"
⋮
"exif:thumbnail:JPEGInterchangeFormat"
"exif:thumbnail:JPEGInterchangeFormatLength"
"exif:thumbnail:ResolutionUnit"
"exif:thumbnail:XResolution"
"exif:thumbnail:YResolution"
"exif:WhiteBalance"
"exif:XResolution"
"exif:YCbCrPositioning"
"exif:YResolution"
"jpeg:colorspace"
"jpeg:sampling-factor"
"unknown"a

```

“”"  
function magickinfo(file::Union{AbstractString,IO})  
wand = MagickWand()  
readimage(wand, file)  
resetiterator(wand)  
getimageproperties(wand, “\*”)  
end

@doc raw"“”  
magickinfo(file::Union{AbstractString,IO}, properties::Union{Tuple,AbstractVector})

Reads an image `file` and returns a Dict containing the values for the requested `properties`.

# Examples

```julia-repl
> magickinfo("IMG_6477.jpeg",
("exif:DateTime","exif:GPSLatitude","exif:GPSLatitudeRef",
"exif:GPSLongitude","exif:GPSLongitudeRef","exif:GPSAltitude"))
Dict{String,Any} with 6 entries:
"exif:GPSLongitudeRef" => "W"
"exif:GPSLatitude" => "44/1, 22/1, 2326/100"
"exif:GPSLatitudeRef" => "N"
"exif:GPSLongitude" => "71/1, 13/1, 5301/100"
"exif:DateTime" => "2020:01:22 13:17:41"
"exif:GPSAltitude" => "261189/757"

```

“”"  
function magickinfo(file::Union{AbstractString,IO}, properties::Union{Tuple,AbstractVector})  
wand = MagickWand()  
readimage(wand, file)  
resetiterator(wand)

props = Dict{String,Any}()  
for p in properties  
props[p] = getimageproperty(wand, p)  
end  
props  
end

---

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [March 3, 2021, 7:05pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/11 "2021-03-03T19:05:12Z")

</div>

Tim,

I forked a branch, added the doc strings, and committed the changes. I’m not sure if anything else is needed for my changes to be seen by others.

Michael

---

<div class="post-metadata">

**Author:** ![michael-prange](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael-prange/32/24070_2.png) [@michael-prange](https://discourse.julialang.org/u/michael-prange)\
**Post date:** [March 3, 2021, 7:10pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/12 "2021-03-03T19:10:17Z")

</div>

Tim,

Sorry for this running commentary. I’ve created a PR. Now do I wait a day or so for comments and then Close Pull Request?

Michael

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 3, 2021, 8:18pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/13 "2021-03-03T20:18:03Z")

</div>

Thanks so much! It’s merged and should come out in a release later today!

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [October 18, 2022, 2:43pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-read-exif-data-from-a-jpg-image/35297/14 "2022-10-18T14:43:41Z")

</div>

> **[GitHub - JuliaImages/ExifViewer.jl: Metadata reader in Julia, wrapper over...](https://github.com/JuliaImages/ExifViewer.jl)**
>
> Metadata reader in Julia, wrapper over LibExif. Contribute to JuliaImages/ExifViewer.jl development by creating an account on GitHub.
