Thank you so much for your help! 

It's working nicely now. I was doing exactly as you said buuut (and I should kick myself for that!) I was mishandling the value associated with the tags :((.

Thanks again, and thanks for the library too!  

2014-06-04 23:19 GMT+02:00 Dan Fandrich <>:
On Wed, Jun 04, 2014 at 10:41:52PM +0200, Lucía Díaz Rodríguez wrote:
> Thank for your answer!!
> I've tried doing what exif_entry_initialize() does but I get a compiler error
> at:
>      exifentry->data = exif_entry_alloc (exifentry, exifentry->size);
> because that is a private function on exif-entry.c. So I've tried doing what
> that function does, that is:
> exifentry->data = exif_mem_alloc (exifentry->priv->mem, exifentry->size);
> but this also fails, because the compiler doesn't know exifentry->priv->mem 
> (error: invalid use of incomplete type ‘ExifEntryPrivate {aka struct
> _ExifEntryPrivate}’).
> And I could find where that is to give some reference to the compiler.

IIRC, the right solution is to create an ExifEntry using exif_entry_new_mem,
passing in an allocator of your own choosing. Then, you can use that allocator
instead of the private one.

> That's why I tried the write.exif.c bit:
> buf = exif_mem_alloc(mem, exifentry->size);
> assert(buf != NULL);
> /* Fill in the entry */
> exifentry->data = (unsigned char *)buf;
> But the firs line results in segmentation fault, so that doesn't work either.

It depends on where you got that mem pointer. Using exif_entry_new_mem, you can
pass in your own (created from exif_mem_new_default) and it will be internally

> So I really don't know what to do to make it work like it is supposed to, that
> why I asked if is true that it works :))
> Thanks again,
> Lucía
> 2014-06-04 21:07 GMT+02:00 Dan Fandrich <>:
>     On Wed, Jun 04, 2014 at 04:33:51PM +0200, Lucía Díaz Rodríguez wrote:
>     > I'm trying to add Exif information to a JPEG file. I've tried the exif
>     command
>     > line tool (v0.6.21) and the libexif API (v0.6.21-1). 
>     > Everything works fine until I get to the GPS information (Latitude,
>     > LatitudeRef, Longitude and LongitudeRef). I'm able to read it if it
>     already
>     > exits but i'm not able to create or modify it.
>     >
>     > Using the exif command line tool (in Mint 16 64bits and also in Ubuntu
>     12.04
>     > 32-bits), like so:
>     >       exif -c --ifd=GPS --tag=0x0001 --set-value="N" foto-exif.mjpg 
>     > I get this error:
>     >       Setting a value for this tag is unsupported!
>     > (Same result using --tag=GPSLatitudeRef).
>     That's a limitation in the command-line program that flows from missing
>     tags in
>     the library. There's no good reason for the tags to be missing, except that
>     it's really a convenience function that most programs don't actually need.
>     It would be possible to add command-line options to exif to support
>     arbitrary
>     tag data; I'm happy to review patches!
>     > Using the libexif API, when I try: exif_entry_initialize (exifentry,
>     tag), the
>     > tag is not listed in the switch cases so default it's used and the entry
>     gets
>     > FORMAT_UNDEFINED and components=0, which doesn't allocate any memory for
>     the
>     > associated data.
>     > Even if I try to initialize the entry myself (like in the write-exif.c
>     example)
>     > I'm not able to do so for the data field (I get a segmentation fault on
>     > exif_mem_alloc(mem, exifentry->size)).
>     That should work fine, except that write-exif.c relies on
>     exif_entry_initialize
>     to create the empty tag, so it's not a complete solution. Take a look at
>     the code
>     in exif_entry_initialize itself to figure out the rest.
>     > Now, I've found a bug report from 2005 (
>     > bugreport.cgi?bug=309127) mentioning the GPS tags editing. In its
>     response it's
>     > stated that editing this sort of tags it's possible since exif 0.6.15. 
>     > Has anything changed since then? If not, would you be so kind as to
>     explain to
>     > me what am I doing wrong? I've already tried all I could think of and got
>     > nowhere.
>     I don't recall what changes were made since then that would affect this,
>     but
>     libexif got more strict in a number of ways since then. I don't think any
>     existing (working) functionality was removed.
>     >>> Dan

Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
libexif-devel mailing list