Exemple #1
0
void
epsilon_exif_info_free (Epsilon_Exif_Info * eei)
{
  if (eei)
    {
      exiffree (eei);
    }
}
Exemple #2
0
/*
 * Scan the JPEG file for Exif data and parse it.
 */
static int
doit(FILE *fp, int n)
{
	int mark, gotapp1, first, rc;
	unsigned int len, rlen;
	unsigned char *exifbuf;
	struct exiftags *t;
	long app1;

	gotapp1 = FALSE;
	first = 0;
	exifbuf = NULL;
	rc = 0;

	while (jpegscan(fp, &mark, &len, !(first++))) {

		if (mark != JPEG_M_APP1) {
			if (fseek(fp, len, SEEK_CUR))
				exifdie((const char *)strerror(errno));
			continue;
		}

		exifbuf = (unsigned char *)malloc(len);
		if (!exifbuf)
			exifdie((const char *)strerror(errno));

		app1 = ftell(fp);
		rlen = fread(exifbuf, 1, len, fp);
		if (rlen != len) {
			fprintf(stderr, "%s: error reading JPEG (length "
			    "mismatch)\n", fname);
			free(exifbuf);
			return (1);
		}

		t = exifscan(exifbuf, len, FALSE);

		if (t && t->props) {
			gotapp1 = TRUE;
			if (lflag)
				rc = listts(t, &lorder[n]);
			else
				rc = procall(fp, app1, t, exifbuf);
		}
		exiffree(t);
		free(exifbuf);
	}

	if (!gotapp1) {
		fprintf(stderr, "%s: couldn't find Exif data\n", fname);
		return (1);
	}

	return (rc);
}
Exemple #3
0
static Epsilon_Exif_Info *
epsilon_read_exif_data (FILE * fp, int dumplvl, int pas)
{
  int mark, gotapp1, first;
  unsigned int len, rlen;
  unsigned char *exifbuf;
  struct exiftags *t = NULL;

  gotapp1 = FALSE;
  first = 0;
  exifbuf = NULL;

  while (jpegscan (fp, &mark, &len, !(first++)))
    {

      if (mark != JPEG_M_APP1)
	{
	  if (fseek (fp, len, SEEK_CUR))
	    exifdie ((const char *) strerror (errno));
	  continue;
	}

      exifbuf = (unsigned char *) malloc (len);
      if (!exifbuf)
	exifdie ((const char *) strerror (errno));

      rlen = fread (exifbuf, 1, len, fp);
      if (rlen != len)
	{
	  exifwarn ("error reading JPEG (length mismatch)");
	  free (exifbuf);
	  return (NULL);
	}

      t = exifparse (exifbuf, len);

      if (t && t->props)
	{
	  gotapp1 = TRUE;

#if 0
	  if (dumplvl & ED_CAM)
	    _epsilon_exif_info_props_get (t->props, ED_CAM, pas);
	  if (dumplvl & ED_IMG)
	    _epsilon_exif_info_props_get (t->props, ED_IMG, pas);
	  if (dumplvl & ED_VRB)
	    _epsilon_exif_info_props_get (t->props, ED_VRB, pas);
	  if (dumplvl & ED_UNK)
	    _epsilon_exif_info_props_get (t->props, ED_UNK, pas);
#endif
	}
      free (exifbuf);
    }

  if (!gotapp1)
    {
      exifwarn ("couldn't find Exif data");
      if (t)
	exiffree (t);
      return (NULL);
    }
  return ((Epsilon_Exif_Info *) t);
}
Exemple #4
0
/*
 * Scan the JPEG file for Exif data and parse it.
 */
static int
doit(FILE *fp, const char *fname)
{
	int mark, gotapp1, first, rc;
	unsigned int len, rlen;
	unsigned char *exifbuf;
	struct exiftags *t;
	long app1;

	gotapp1 = FALSE;
	first = 0;
	exifbuf = NULL;
	rc = 0;

	while (jpegscan(fp, &mark, &len, !(first++))) {

		if (mark != JPEG_M_APP1) {
			if (fseek(fp, len, SEEK_CUR))
				exifdie((const char *)strerror(errno));
			continue;
		}

		exifbuf = (unsigned char *)malloc(len);
		if (!exifbuf)
			exifdie((const char *)strerror(errno));

		app1 = ftell(fp);
		rlen = fread(exifbuf, 1, len, fp);
		if (rlen != len) {
			fprintf(stderr, "%s: error reading JPEG (length "
			    "mismatch)\n", fname);
			free(exifbuf);
			return (1);
		}

		gotapp1 = TRUE;
		t = exifscan(exifbuf, len, FALSE);

		if (t && t->props) {
			if (bflag || com)
				rc = writecom(fp, fname, app1,
				    findprop(t->props, tags,
				    EXIF_T_USERCOMMENT), exifbuf, t->md.btiff);
			else
				rc = printcom(fname, findprop(t->props, tags,
				    EXIF_T_USERCOMMENT), t->md.btiff);
		} else {
			fprintf(stderr, "%s: couldn't find Exif properties\n",
			    fname);
			rc = 1;
		}
		exiffree(t);
		free(exifbuf);
	}

	if (!gotapp1) {
		fprintf(stderr, "%s: couldn't find Exif data\n", fname);
		return (1);
	}

	return (rc);
}