https://foro.gambas-es.org/viewtopic.php?f=17&t=7851&p=47342#p47342
-----------------------------------
vuott
Miercoles, 01 Enero 2020, 23:07

Re: Alguna Libreria Para Leer Metadatos De Fotos.
-----------------------------------
[quote user="tincho" post="47300"]Hola Vuott.
Has implementado alguna función externa de C con alguna librería que permita extraer la fecha de una foto jpeg y algún que otro dato relevante ?
[/quote]

Hola tincho,
prueba este nuevo codigo ahora:

[code linenumbers=false syntax=gambas]Private content_count As Integer
Private ifd As Integer
Private entry_count As Integer


Library "libexif:12.3.3"

Public Struct ExifData
  ifd[5] As Pointer
  data As Pointer
  size As Integer
  priv As Pointer
End Struct

Public Struct ExifEntry
  tag As Integer
  format_ As Integer
  components As Long
  data As Pointer
  size As Integer
  parent As Pointer
  priv As Pointer
End Struct

' ExifData *exif_data_new_from_file (const char *path)
' Allocate a new #Pointer and load EXIF data from a JPEG file.
Private Extern exif_data_new_from_file(path As String) As ExifData

' ExifByteOrder exif_data_get_byte_order  (ExifData *data)
' Return the byte order in use by this EXIF structure.
Private Extern exif_data_get_byte_order(data As ExifData) As Integer

' const char *exif_byte_order_get_name (ExifByteOrder order)
' Return a short, localized, textual name for the given byte order.
Private Extern exif_byte_order_get_name(order As Integer) As String

' void exif_data_foreach_content (ExifData *data, PointerForeachContentFunc func, void *user_data)
' Execute a function on each IFD in turn.
Private Extern exif_data_foreach_content(data As ExifData, func As Pointer, user_data As Pointer)

' void exif_content_foreach_entry (ExifContent *content, ExifContentForeachEntryFunc func, void *user_data)
' Executes function on each EXIF tag in this IFD in turn.
Private Extern exif_content_foreach_entry(content As Pointer, func As Pointer, user_data As Pointer)

' ExifIfd exif_content_get_ifd (ExifContent *c)
' Return the IFD number in which the given #ExifContent is found.
Private Extern exif_content_get_ifd(c As Pointer) As Integer

' const char *exif_entry_get_value (ExifEntry *entry, char *val, unsigned int maxlen)
' Return a localized textual representation of the value of the EXIF entry.
Private Extern exif_entry_get_value(entry As ExifEntry, _val As Pointer, maxlen As Integer) As String

' const char *exif_tag_get_name_in_ifd(ExifTag tag, ExifIfd ifd)
' Return a textual name of the given tag when found in the given IFD.
Private Extern exif_tag_get_name_in_ifd(tag As Integer, ifd As Integer) As String

' const char *exif_format_get_name (ExifFormat format)
' Return a textual representation of the given EXIF data type.
Private Extern exif_format_get_name(format_ As Integer) As String

' void exif_data_unref (ExifData *data)
Private Extern exif_data_unref(data As ExifData)


Public Sub Main()
 
  Dim ed As ExifData
  Dim jpg As String
  Dim callback_data As Pointer

  jpg = "/ruta/del/archivo.jpg"
  Print "File immagine:   "; jpg
  
  ed = exif_data_new_from_file(jpg)
  If IsNull(ed) Then Error.Raise("Errore !")
  
  Print "Ordine dei byte: "; exif_byte_order_get_name(exif_data_get_byte_order(ed))
  
  exif_data_foreach_content(ed, data_foreach_func, callback_data)
 
  exif_data_unref(ed)
  
End


Private Function data_foreach_func(content As Pointer, callback_data As Pointer)
  
  ifd = exif_content_get_ifd(content)
  Print "  Content :"; content_count, "ifd= "; ifd
  
  exif_content_foreach_entry(content, content_foreach_func, callback_data)
  
  Inc content_count
  
End


Private Function content_foreach_func(entry As Pointer, callback_data As Pointer)

  Dim buf As New Byte[2000]
  Dim ent As ExifEntry
  
  ent = entry
  
  exif_entry_get_value(entry, buf.Data, buf.Count)
  
  Print "   Entry"; entry_count; ": "; exif_tag_get_name_in_ifd(ent.tag, ifd); "("; exif_format_get_name(ent.format_); ")"
  Print "      Size, Comps: "; ent.size; ", "; ent.components
  Print "      Value: "; exif_entry_get_value(ent, buf.Data, buf.Count)
  Inc entry_count
  
End[/code]


