2006.08.11 19:49 "RE: [Tiff] Newbie RICHTIFFIPTC query -- code snippet (sample usage of TIFFTAG_RICHTIFFIPTC)", by

2006.08.11 15:00 "Re: [Tiff] Newbie RICHTIFFIPTC query", by Dermot Paikkos

Hi,

On 11 Aug 2006 at 10:15, Sean Burke wrote:

> Hey.

> According to the man page on TIFFGetField, TIFFTAG_RICHTIFFIPTC > returns two parameters: a count variable (uint32) and a point to an

> array (void*). Sooooo..... Your primitive should look something like > this: uint32 *myCount; //depending on what your data looks like, one

> of the following. // since you are using strcat, I assume that you > will want the first one char *myData; uint16 *myData; uint32 *myData;

The data types is one of the problems, I am not sure how to determine what type of data I have in myData. There is character data in there somewhere but I am unable to find a way to assign it so I can compare it. If I use char *data I do avoid the "void reference" error though.

The information at http://www.awaresystems.be/imaging/tiff/tifftags/iptc.html

says:

IFD Image
Code 33723 (hex 0x83BB)
Name IPTC
LibTiff name TIFFTAG_RICHTIFFIPTC
Type UNDEFINED or BYTE
Count N
Default None

Presumably count is the size of the data in bytes. So I should loop through data until = count to slurp up the contents of data. But count in my test file is -17231916, how can I loop through that?

> TIFFGetField(tif, TIFFTAG_RICHTIFFIPTC, myCount, myData);
>
> Also, if your data is actually a string, the strcat is unnecessary

> since C treats all strings as char arrays. Try putting the following > line in to see if you need strcat:

>

> Finally, (for my own selfish reasons) what the heck is an IPTC?

IPTC is just one of a few ways to embed data into a file. The IPTC format allows for an array of keywords, date created, captions and copyright.

Thanx for the help.
Dp.

> Sean
>
> Beginner wrote:

First off, I am very in-experienced with C.

I would like to be able to retieve the IPTC data from a TIFF file. I have managed to get fairly close to my goal thanx to reading the archives but I need a bit of help and hopefully some explanations of what is wrong.

The program below compiles (GCC 3.4.2) with the error: warning: dereferencing `void *' pointer

The IPTC was addded to the TIFF file via PhotoShop 7, so it pre-XMP. When it runs I do get all the text I put into the file but it seg faults. I think the fault is because I strcat data that doesn't exist

in my loop. What I'd like is some way to 1) to know where to start reading the data from 2) who to check the data is text that come from data, 3) any other suggested sanity checks anyone can think of.

Is that a tall order? If so sorry but the books I have are not really

helping me understand how to deal with a void pointers.

TIA.

=============

include <stdio.h>
include <tiffio.h>

main()

 int i;

  uint16 count;                /* unit32 gives me no text at all */

 void *data;
 char iptc_data[600];

  TIFF* tif = TIFFOpen("test.tif", "r");
  if (tif == NULL) {
        printf("Failed to open file\n");
        exit(8);
  }
  if (TIFFGetField(tif, TIFFTAG_RICHTIFFIPTC, &count, &data) == 0) {
          printf("No IPTC Tag found\n");
          exit(8);
  }
  printf("Size of IPTC Tag is %d bytes. %s.\n", count, &data);

  for ( i = 0; i < count; ++i) {
        strcat(iptc_data, &data[i]);
  }

  printf("%s\n", iptc_data);

TIFFClose(tif);

  return 0;
}

=================

>
> --
> Sean Burke
> Imaging Analysis Specialist
> Albert Einstein College of Medicine
> 1300 Morris Park Avenue
> Bronx, NY 10461
> PH: 718.430.8628
>
>