JuliaImages / ExifViewer.jl

Metadata reader in Julia, wrapper over LibExif
https://juliaimages.org/ExifViewer.jl/dev/
MIT License
28 stars 1 forks source link

Read Operations #3

Closed ashwani-rathee closed 2 years ago

ashwani-rathee commented 2 years ago

This will include read operations on tags like:

Focus:

tags.jl need to export all tags which it doesn't yet and need to decide on the names(IMAGE-WIDTH still looks long and maybe there is a better way to do it), there are some issue with clang.jl wrapper generation that needs a fix so I use a old version from here: https://github.com/ashwani-rathee/io-project/blob/main/exifviewer/gen/LibExif.jl Also need to check if we have some image availabe in testimages.jl for testing purpose or do I need to include it?

Able to do:

julia> read_metadata("test/test_images/test.jpg")
Dict{Any, Any} with 12 entries:
  "EXIF_TAG_DOCUMENT_NAME"     => "Test_Image"
  "EXIF_TAG_ORIENTATION"       => "Bottom-right"
  ⋮                            => ⋮

julia> read_tags("test/test_images/test.jpg", tags=[ARTIST, Y_RESOLUTION, X_RESOLUTION])
Dict{Any, Any} with 3 entries:
  "EXIF_TAG_Y_RESOLUTION" => "72"
  "EXIF_TAG_ARTIST"       => "Ashwani"
  "EXIF_TAG_X_RESOLUTION" => "72"
johnnychen94 commented 2 years ago

Feel free to add new images to TestImages.jl.

ashwani-rathee commented 2 years ago

Couple of things to cover in next commit:

Also if possible:

ashwani-rathee commented 2 years ago

Getting permission for some more test images from libexif team: https://github.com/libexif/libexif/issues/88 I tested mnote functionality on https://github.com/libexif/libexif/blob/master/test/testdata/canon_makernote_variant_1.jpg and it works

julia> a = read_tags(filepath1; read_all=true,read_mnote=true)
Dict{String, Any} with 105 entries:
  "MNOTE_FLASH_EXPOSURE_COMPENSATION" => "0.00 EV"
  "MNOTE_SELF-TIMER"                  => "Off"
  "MNOTE_FOCUS_RANGE"                 => "Auto"
  "MNOTE_FOCAL_PLANE_X_SIZE"          => "7.39 mm"
  "MNOTE_EXPOSURE_COMPENSATION"       => "0.00 EV"
  "EXIF_TAG_SENSING_METHOD"           => "One-chip color area sensor"
  "MNOTE_EASY_SHOOTING_MODE"          => "Landscape"
  ⋮                                   => ⋮

And yes we have their permission now!

ashwani-rathee commented 2 years ago

Not entirely sure why the segmentation faults are happening now tbh, sometimes I am able to read all the maker note tags from those new test images(https://github.com/ashwani-rathee/exif-sampleimages) but sometimes it all just starts failing. But I think it comes from here when reading the maker note tags, also I have seen the mnote tags fail in tests but they generally seem to work in repl.

mnote = LibExif.exif_mnote_data_get_name(md_ptr, i) # so it give a pointer to location of name of tag but i am unable to 
# decide how far to read so its like [83,100,91,63,0,120...] and we have mnote which is address of 83, 
# so ideallly we should have size of name, so we just read till 0 and then convert it to UInt8 and then to string
if (mnote == C_NULL) continue end
data = unsafe_wrap(Array, mnote, 30) # but given we don't have size of name(haven't been able to find it), i read 30 address which might 
# not the smart thing to do, haven't been able to find the size of name in documentation

Or I am missing some understanding of resources management, freeing pointers or something like that

Also, I think its best if we remove fixformat for now, there are some conspicous errors showing up there too.

johnnychen94 commented 2 years ago

@ashwani-rathee I think this PR is almost finished, can you try to finish the unresolved comments so that we can merge it (for GSoC evaluation purposes)?

johnnychen94 commented 2 years ago

@ashwani-rathee nice work!