| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2009.10.28 16:28 "Re: extending tags in "a"ppend mode?", by Juergen BuchmuellerOn Wed, 28 Oct 2009 12:02:09 -0400 Frank Warmerdam <warmerdam@pobox.com> wrote: > Juergen, > > It should be possible to extend the first directory with new tags by opening > in "r+" (update) mode, setting the tags and closing. I don't know why you are > seeing the behavior you encountered. I would have expected it to attempt to > append a new image directory and complain about your not providing a complete > set of tags to define an image. Ok, I didn't know that "r+" was supported because it isn't mentioned in the docs. > It might be helpful if you provided a minimal program and file demonstrating > your problem. See attachment. This crashes when I try to run it on the file: http://pmbits.ath.cx/RECV002.TIF Compiled with (adapt include + lib paths): gcc -I/usr/pkg/include -Wl,-R/usr/pkg/lib \ -L/usr/pkg/lib -ltiff -o addtags addtags.c Run with: ./addtags somewhere/RECV002.TIF Stack backtrace: Program terminated with signal 11, Segmentation fault. #0 0x00007f7ffd98eb6a in _malloc_prefork () from /usr/lib/libc.so.12 (gdb) bt #0 0x00007f7ffd98eb6a in _malloc_prefork () from /usr/lib/libc.so.12 #1 0x00007f7ffd98edde in free () from /usr/lib/libc.so.12 #2 0x00007f7ffdc08959 in TIFFCleanup () from /usr/pkg/lib/libtiff.so.3 #3 0x00007f7ffdc089e1 in TIFFClose () from /usr/pkg/lib/libtiff.so.3 #4 0x0000000000400dbe in main () To me it looks like a double free() of some kind!? > Also, in place update of directories is always an iffy procedure with libtiff > but I would strongly encourage using the most recent release (3.9.1?) if you > are trying this. Yes, on my system (NetBSD-5.0.1) there is libtiff-3.9.1 installed. Thanks, Juergen #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <tiffio.h> static const char *some_strings[] = { "Hello, world!", "foo", "bar", "baz" }; int main(int argc, char **argv) { TIFF *hTIFF; TIFFFieldInfo *apptags; char buff[32]; const char *str; uint32_t n, ntags; int32_t res; hTIFF = TIFFOpen(argv[1], "r+"); ntags = 3; apptags = calloc(ntags, sizeof(TIFFFieldInfo)); for (n = 0; n < ntags; n++) { uint16_t id = 10000 + n; apptags[n].field_tag = id; apptags[n].field_readcount = TIFF_VARIABLE; apptags[n].field_writecount = TIFF_VARIABLE; apptags[n].field_type = TIFF_ASCII; apptags[n].field_bit = FIELD_CUSTOM; apptags[n].field_oktochange = 1; apptags[n].field_passcount = 0; snprintf(buff, sizeof(buff), "Tag %d", id); apptags[n].field_name = strdup(buff); } TIFFMergeFieldInfo(hTIFF, apptags, ntags); for (n = 0; n < ntags; n++) { str = some_strings[n]; res = TIFFSetField(hTIFF, apptags[n].field_tag, str); printf("set tag:%u to \"%s\" res:%d\n", apptags[n].field_tag, str, res); } TIFFClose(hTIFF); for (n = 0; n < ntags; n++) { if (apptags[n].field_name) free(apptags[n].field_name); } free(apptags); return 0; } |
|||||||