Example #1
0
File: exif.c Project: 0ion9/feh
/* Show the given MakerNote tag if it exists */
void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize)
{
  ExifMnoteData *mn = NULL; 
  int i, num;
  char buf[1024];

  if ( (d!=NULL) && (buffer!=NULL) && (maxsize > 0) )
  {
    mn = exif_data_get_mnote_data(d);
  }
  else
  {
    return;
  }
    
  if ( mn != NULL ) 
  {
    num = exif_mnote_data_count(mn);

    /* Loop through all MakerNote tags, searching for the desired one */
    for (i=0; i < num; ++i) 
    {
      D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i), 
        exif_mnote_data_get_id(mn, i),
        exif_mnote_data_get_name(mn,i), 
        exif_mnote_data_get_title(mn, i) ));
      
      if (exif_mnote_data_get_id(mn, i) == tag) 
      {
        if (exif_mnote_data_get_value(mn, i, buf, sizeof(buf))) 
        {
          /* Don't bother printing it if it's entirely blank */
          exif_trim_spaces(buf);
          if (*buf != '\0')
          {
             D(("%s\n", buf));
             snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_mnote_data_get_title(mn, i), buf);
          }
        }
      }
    }
  }
}
Example #2
0
static int
test_exif_data (ExifData *d)
{
	unsigned int i, c;
	char v[1024], *p;
	ExifMnoteData *md;

	fprintf (stdout, "Byte order: %s\n",
		exif_byte_order_get_name (exif_data_get_byte_order (d)));

	fprintf (stdout, "Parsing maker note...\n");
	md = exif_data_get_mnote_data (d);
	if (!md) {
		fprintf (stderr, "Could not parse maker note!\n");
		exif_data_unref (d);
		return 1;
	}

	fprintf (stdout, "Increasing ref-count...\n");
	exif_mnote_data_ref (md);

	fprintf (stdout, "Decreasing ref-count...\n");
	exif_mnote_data_unref (md);

	fprintf (stdout, "Counting entries...\n");
	c = exif_mnote_data_count (md);
	fprintf (stdout, "Found %i entries.\n", c);
	for (i = 0; i < c; i++) {
		fprintf (stdout, "Dumping entry number %i...\n", i);
		fprintf (stdout, "  Name: '%s'\n",
				exif_mnote_data_get_name (md, i));
		fprintf (stdout, "  Title: '%s'\n",
				exif_mnote_data_get_title (md, i));
		fprintf (stdout, "  Description: '%s'\n",
				exif_mnote_data_get_description (md, i));
		p = exif_mnote_data_get_value (md, i, v, sizeof (v));
		if (p) { fprintf (stdout, "  Value: '%s'\n", v); }
	}

	return 0;
}
Example #3
0
static void
exif_entry_cb (ExifEntry *entry, gpointer data)
{
	GtkTreeStore *store;
	EogExifDetails *view;
	EogExifDetailsPrivate *priv;
	ExifCategory cat;
	ExifIfd ifd = exif_entry_get_ifd (entry);
	char *path;
	char b[1024];
	const gint key = ifd << 16 | entry->tag;

	/* This should optimize away if comparision is correct */
	g_warn_if_fail (EXIF_IFD_COUNT <= G_MAXUINT16);

	view = EOG_EXIF_DETAILS (data);
	priv = view->priv;

	store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));

	/* Take the tag's IFD into account when caching their GtkTreePaths.
	 * That should fix key collisions for tags that have the same number
	 * but are stored in different IFDs. Exif tag numbers are 16-bit
	 * values so we should be able to set the high word to the IFD number.
	 */
	path = g_hash_table_lookup (priv->id_path_hash, GINT_TO_POINTER (key));

	if (path != NULL) {
		set_row_data (store,
			      path,
			      NULL,
			      exif_tag_get_name_in_ifd (entry->tag, ifd),
			      eog_exif_entry_get_value (entry, b, sizeof(b)));
	} else {

		ExifMnoteData *mnote = (entry->tag == EXIF_TAG_MAKER_NOTE ?
			exif_data_get_mnote_data (entry->parent->parent) : NULL);

		if (mnote) {
			// Supported MakerNote Found
			unsigned int i, c = exif_mnote_data_count (mnote);

			for (i = 0; i < c; i++) {
				path = g_hash_table_lookup (priv->id_path_hash_mnote, GINT_TO_POINTER (i));
				if (path != NULL) {
					set_row_data (store, path, NULL,
						exif_mnote_data_get_title (mnote, i),
						exif_mnote_data_get_value (mnote, i, b, sizeof(b)));
				} else {
					path = set_row_data (store,
							     NULL,
							     exif_categories[EXIF_CATEGORY_MAKER_NOTE].path,
							     exif_mnote_data_get_title (mnote, i),
							     exif_mnote_data_get_value (mnote, i, b, sizeof(b)));
					g_hash_table_insert (priv->id_path_hash_mnote, GINT_TO_POINTER (i), path);
				}
			}
		} else {
			cat = get_exif_category (entry);

			path = set_row_data (store,
					     NULL,
					     exif_categories[cat].path,
					     exif_tag_get_name_in_ifd (entry->tag, ifd),
					     eog_exif_entry_get_value (entry, b,
								    sizeof(b)));

			g_hash_table_insert (priv->id_path_hash,
					     GINT_TO_POINTER (key),
					     path);
		}
	}
}
Example #4
0
static int Dgetmnotedata (lua_State *L) { /** data.mnotedata */
  ExifData *data = checkdata(L);
  pushmnote_data(L, exif_data_get_mnote_data(data));
  return 1;
}