Librerias Para Leer Metadatos De Fotos Y Videos.


Goto page Previous  1, 2, 3  Next

Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
tincho escribió: [Ver mensaje]
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 ?


Hola tincho,
prueba este nuevo codigo ahora:

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

Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
cogier escribió: [Ver mensaje]
Citar:
He probado a hacer el paquete instalador para dejarlo instalado y lo compilo y instalo bien pero me da error de libreria →

/usr/bin/PhotoEXIF
gb.gui.qt: warning: 'gb.qt5' component not found, using 'gb.qt4' instead

(gbr3:11646): Gtk-WARNING **: Incapaz de localizar motor de temas na module_path: "xfce",...


Instalé 'Xubuntu 18.03' y gambas. Luego descargué 'PhotoEXIF' de la 'Granja', y funcionó sin problemas.

Google se quejó de 'FireFox' pero 'Bing' estaba bien.

No he intentado hacer un archivo '.deb'.

screenshot_photoexif


Gracias por el dato mirare por la "Granja".

El programa es genial porque es un interfaz grafico a las opciones que sueles usar por comandos con esa herramienta, creo que tengo alguna aplicacion grafica similar instalada en este PC pero no lo se con total seguridad ni me acuerdo del nombre tendria que buscar en los menus o programas script y como esta aplicacion de front end para Exiftool esta hecha en gambas pues me interesa porque me gustan estas aplicaciones hechas en este lenguaje y que te ahorra abrir terminal y darle a comandos si lo puedes hacer mediante clicks tiene su uso las dos cosas estan bien a veces mejor comando y a veces mejor por boton.

Gracias.

Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
vuott escribió: [Ver mensaje]
Hola tincho,
prueba este nuevo codigo ahora:

Private content_count As Integer
Private ifd As Integer
Private entry_count As Integer

Library "libexif:12.3.3"
'...
End


Perfecto Vuott, lo probé y funciona muy bien y muy rápido.
Estoy adaptando la clase para poder usarla en varios programas de manejo de fotos.
Siempre haces estos programas que funcionan súper rápido
Muchas gracias por compartirlos.
Saludos.

Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
Bueno ya esta, logre adaptar el código paara poder usarlo instanciado en otros programas.
' gambas class file

Export

Private content_count As Integer
Private ifd As Integer

Public ctn As New Collection
'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 _new()

End

Public Sub exifdat(f As String) As Collection

Dim ed As ExifData
'Dim jpg As String
Dim callback_data As Pointer

ctn.Clear

'jpg = "/ruta/del/archivo.jpg"
'Print "File immagine: "; jpg
If Exist(f) Then
ed = exif_data_new_from_file(f)
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)
Endif

Return Normalize(ctn)

End

Private Function Normalize(cn As Collection) As Collection

Dim tg As Variant
Dim co As New Collection

For Each tg In cn
Select cn.Key
Case "Model"
co.Add(tg, "CameraModel")
Case "Make"
co.Add(tg, "CameraMaker")
Case "DateTimeOriginal", "Date/Time"
co.Add(tg, "DateTimeOriginal")
Case Else
co.Add(tg, cn.Key)
End Select
Next

If co.Exist("Resolution") = False Then
If co.Exist("PixelXDimension") And co.Exist("PixelYDimension") Then
co.Add(co["PixelXDimension"] & "X" & co["PixelYDimension"], "Resolution")
Endif
Endif

Return co

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)

ctn.Add(exif_entry_get_value(ent, buf.Data, buf.Count), exif_tag_get_name_in_ifd(ent.tag, ifd))

'Inc entry_count

End

Le modifique algunas nombres de tag para que sea compatible con mis programas.
Al intentar leer metadatos de archivos de video no funciono. Supongo que la librería libexif no soportam mas que JPEG.
En este sitio dice que solo es para JPEG
https://libexif.github.io/api/exif-...ad7ab2d28d8b8d2
Así que de momento para otros formatos de archivo seguire usando la herramienta Exiftool a travez de la terminal.
Uso shell ya que como es una libreria perl no se puede usar como Extern verdad? o si se puede?

Saludos.

Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
cogier escribió: [Ver mensaje]
Hay un programa llamado 'exiftool' que funciona bien.
Echa un vistazo a mi programa de gambas aquí. (Lo siento pero está en inglés)
photoexif1

Creo que tu programa se vería beneficiado si usas la clase de Vuott que implementa libexif con Extern.
Y por cierto, que antes me olvide de decirlo, muy buen programa.
Saludos.

Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
tincho escribió: [Ver mensaje]
Uso shell ya que como es una libreria perl no se puede usar como Extern verdad? o si se puede?

Con Extern solo C: librerias .so .

Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
vuott escribió: [Ver mensaje]
Con Extern solo C: librerias .so .

Ok, me lo imaginaba.
Saludos.

Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
tincho escribió: [Ver mensaje]
Al intentar leer metadatos de archivos de video no funciono

Hola tincho,
prueba este codigo con la libreria libvlc:

Library "libvlc:5.6.0"

Public Struct video_track_t
i_height As Integer
i_width As Integer
i_sar_num As Integer
i_sar_den As Integer
i_frame_rate_num As Integer
i_frame_rate_den As Integer
i_orientation As Integer
i_projection As Integer
pose1 As Single
pose2 As Single
pose3 As Single
pose4 As Single
i_multiview As Byte
End Struct

Public Struct audio_track_t
i_channels As Integer
i_rate As Integer
End Struct

Private Enum libvlc_media_parse_local = 0,
libvlc_media_parse_network,
libvlc_media_fetch_local,
libvlc_media_fetch_network = 4,
libvlc_media_do_interact = 8

' libvlc_instance_t * libvlc_new (int argc, const char *const *argv)
' Create And initialize a libvlc instance.
Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer

' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path)
' Create a media for a certain file path.
Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer

' int libvlc_media_parse_with_options (libvlc_media_t *p_md, libvlc_media_parse_flag_t parse_flag, int timeout)
' Parse the media asynchronously with options.
Private Extern libvlc_media_parse_with_options(p_md As Pointer, parse_flag As Integer, timeout As Integer) As Integer

' libvlc_time_t libvlc_media_get_duration(libvlc_media_t *p_md)
' Get duration (in ms) of media descriptor object item.
Private Extern libvlc_media_get_duration(p_md As Pointer) As Long

' char* libvlc_media_get_meta (libvlc_media_t * p_md, libvlc_meta_t e_meta)
' Read the meta of the media.
Private Extern libvlc_media_get_meta(p_md As Pointer, e_meta As Integer) As String

' unsigned libvlc_media_tracks_get (libvlc_media_t * p_md, libvlc_media_track_t *** tracks)
' Get media descriptor's elementary streams description.
Private Extern libvlc_media_tracks_get(p_md As Pointer, tracks As Pointer) As Integer

' const char * libvlc_media_get_codec_description (libvlc_track_type_t i_type, uint32_t i_codec)
' Get codec description from media elementary stream.
Private Extern libvlc_media_get_codec_description(i_type As Integer, i_codec As Integer) As String

' void libvlc_media_release (libvlc_media_t *p_md)
' Decrement the reference count of a media descriptor object.
Private Extern libvlc_media_release(p_md As Pointer)

' libvlc_release (libvlc_instance_t * p_instance)
' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero.
Private Extern libvlc_release(p_instance As Pointer)


Public Sub Main()

Dim inst, md, p1, p2 As Pointer
Dim tm As Long
Dim b As Byte
Dim s As String
Dim tp, i As Integer
Dim vt As Video_track_t
Dim at As Audio_track_t
Dim meta As String[] = ["Title:", "Artist:", "Genre", "Copyright:", "Album", "TrackNumber:",
"Description:", "Rating:", "Date:", "Setting:", "URL:",
"Language:", "NowPlaying:", "Publisher:", "EncodedBy:", "ArtworkURL:",
"TrackID:", "TrackTotal:", "Director:", "Season:", "Episode:",
"ShowName:", "Actors:", "AlbumArtist:", "DiscNumber:", "DiscTotal:"]
Dim orient As String[] = ["Normal", "Flipped horizontally", "Flipped vertically", "Rotated 180 degrees",
"Transposed", "Rotated 90 degrees clockwise", "Rotated 90 degrees anti-clockwise", "Anti-transposed"]

s = "/ruta/del/archivo/video"
Print "Nome file: "; s

inst = libvlc_new(0, Null)

md = libvlc_media_new_path(inst, s)

libvlc_media_parse_with_options(md, libvlc_media_parse_local, 0)

Sleep 0.1

tm = libvlc_media_get_duration(md)
Print "Durata: "; Date(0, 0, 0, 0, 0, 0, tm)

Print "\n- Metadati -"
For b = 0 To meta.Max
s = libvlc_media_get_meta(md, b)
If Not IsNull(s) Then Print meta[b]; String(17 - Len(meta[b]), Chr(32)); s
Next

Print "\n- Codificatore -"
p1 = Alloc(SizeOf(gb.Pointer), 3)
p2 = VarPtr(p1)

i = libvlc_media_tracks_get(md, VarPtr(p2))
For b = 0 To i - 1
tp = Int@(Pointer@(p2 + (SizeOf(gb.Pointer) * b)) + 12)
Print "Codifica: "; libvlc_media_get_codec_description(tp, Int@(Pointer@(p2 + (SizeOf(gb.Pointer) * b))))
Print "Tipo media: ";
Select Case tp
Case -1
Print "Unknown"
Case 0
Print "Audio"
at = Pointer@(Pointer@(p2 + (SizeOf(gb.Pointer))) + 24)
With at
Print "Canali: "; at.i_channels
Print "Frequenza camp.: "; at.i_rate
End With
Case 1
Print "Video"
vt = Pointer@(Pointer@(p2) + 24)
With vt
Print "Risoluzione: "; .i_width; "x"; .i_height
Print "Fotogrammi/sec.: "; .i_frame_rate_num
Print "Orientazione: "; orient[.i_orientation]
End With
Case 2
Print "Text"
End Select
Print
Next


' Libera la memoria:
Free(p1)
libvlc_media_release(md)
libvlc_release(inst)

End

Last edited by vuott on Saturday, 04 January 2020, 01:28; edited 5 times in total
Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
Tengo un problema extraño en la granja de gambas - estoy en otro PC que es de 32 bits y me logeo y bajo o instalo el programa via la granja de gambas y sin darme mensaje de error me dice que lo instala o baja pero no lo tengo por ningun lado y comprobe /usr/bin a ver si no me salia en el menu pero me metia el programa en el camino y no estaba tampoco.

Ya me paso esto algunas veces unos programas se bajan y instalan bien pero otros no. Me acuerdo de algo similar por ejemplo con el juego 1945 que por mucho que instalaba no habia lanzador ni eu menu ni en camino de /usr/bin.
Lo hice funcionar bajando el debian por https://jsbsan.blogspot.com/2014/09/1945-el-juego.html

No se si esto os suele pasar pero podria ser por la maquina ser 32 bits y esos paquetes no estan en esa arquitectura o bien no existen?
No hay mensaje ninguno en la granja y el programa sale como bajado o instalado, aunque reintentes una cosa o otra muchas veces.



2020-01-03-145249-1440x900-scrot

Last edited by portaro on Friday, 03 January 2020, 15:55; edited 1 time in total
Profile PM  
Subject: Re: Alguna Libreria Para Leer Metadatos De Fotos.
vuott escribió: [Ver mensaje]
tincho escribió: [Ver mensaje]
Al intentar leer metadatos de archivos de video no funciono

Hola tincho,
prueba este codigo con la libreria libvlc:

Ok, probare y comento luego. gracias Vuott.
Salludos.

Profile PM  
Goto page Previous  1, 2, 3  Next

Page 2 of 3


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Design by DiDiDaDo

Generation Time: 0.2704s (PHP: 57% SQL: 43%)
SQL queries: 25 - Debug Off - GZIP Enabled