From: Antonio S. <sc...@te...> - 2004-04-22 20:30:19
|
Hi, Since I did not find the 0.6.9 tar I updated from CVS to compile it and= =20 here are some comments: 1) Would be very nice to have a function like: const char * exif_tag_get_name_index (unsigned int i, ExifTag *tag) { if (!ExifTagTable[i].name) return NULL; *tag =3D ExifTagTable[i].tag; return (ExifTagTable[i].name); } in "exif-tag.c". It allows me to scan over all the defined tags. 2) The file "exif-data.c" depends on the header file "jpeg-marker.h" that=20 it is in the pack, but outside the library folder. Why not to move this=20 header to the libexif folder? Also Open Watcom complained about it: libjpeg/jpeg-marker.h(27): Error! E1115: Incomplete enum declaration I change to the old version. 3) I created a simple "_stdint.h" by hand from Cygwin "stdint.h", all the=20 platforms I use the types used have fixed sizes. The "_stdint.h" is a good= =20 solution for the library users. 4) I still use the same "config.h" that I mention before: #define GETTEXT_PACKAGE "libexif-9" #ifdef WIN32 #define snprintf _snprintf #endif 5) I have to edit the function exif_entry_initialize from "exif-entry.c".=20 There are lots of uninitialized tags. I simply replace the function with my= =20 version. Then saving exif tags in jpeg came back to normal. That=B4s it. This is working in Windows (gcc3, Mingw3, OpenWatcom, VC6= and=20 VC7) and in UNIX (Linux, IRIX, AIX and SunOS). libexif is used internally= =20 by an also free library called IM. I updated the library this month. You=20 may find it at: http://www.tecgraf.puc-rio.br/im Issues 1 and 2 are not a big deal, but I would appreciate if you guys=20 can think about issue 5. I can send you my version of the function attached. Best, scuri |
From: Lutz <lu...@us...> - 2004-05-02 20:46:04
|
On Thu, 2004-04-22 at 22:30, Antonio Scuri wrote: > 1) Would be very nice to have a function like: >=20 > const char * > exif_tag_get_name_index (unsigned int i, ExifTag *tag) Why don't you scan like this:=20 for (i =3D 0; i < 0xffff; i++) if (exif_tag_get_name (i) !=3D NULL) (...) > 2) The file "exif-data.c" depends on the header file "jpeg-marker.h" th= at=20 > it is in the pack, but outside the library folder. Why not to move this= =20 > header to the libexif folder? Actually, the include statement can be replaced by 2 defines (JPEG_MARKER_*). Patches are welcome. >=20 > Also Open Watcom complained about it: >=20 > libjpeg/jpeg-marker.h(27): Error! E1115: Incomplete enum declaration >=20 > I change to the old version. Fixed. > 3) I created a simple "_stdint.h" by hand from Cygwin "stdint.h", all t= he=20 > platforms I use the types used have fixed sizes. The "_stdint.h" is a g= ood=20 > solution for the library users. I am not sure but I think people are currently trying to fix that (or have already been done it). > 4) I still use the same "config.h" that I mention before: >=20 > #define GETTEXT_PACKAGE "libexif-9" >=20 > #ifdef WIN32 > #define snprintf _snprintf > #endif On my system, config.h gets created by autoheader. I am not sure what the official (GNU whatever) way is for handling this on WIN32. > 5) I have to edit the function exif_entry_initialize from "exif-entry.c= ".=20 > There are lots of uninitialized tags. I simply replace the function wit= h my=20 > version. Then saving exif tags in jpeg came back to normal. What is your version? Could you produce a patch against CVS? Regards Lutz M=FCller |
From: Antonio S. <sc...@te...> - 2004-05-02 23:12:02
|
At 17:47 2/5/2004, Lutz M=FCller wrote: >On Thu, 2004-04-22 at 22:30, Antonio Scuri wrote: > > 1) Would be very nice to have a function like: > > > > const char * > > exif_tag_get_name_index (unsigned int i, ExifTag *tag) > >Why don't you scan like this: > >for (i =3D 0; i < 0xffff; i++) > if (exif_tag_get_name (i) !=3D NULL) > (...) Because this is very inefficient. The function exif_tag_get_name has a=20 loop looking for tag "i" every time is called. > > 5) I have to edit the function exif_entry_initialize from= "exif-entry.c". > > There are lots of uninitialized tags. I simply replace the function=20 > with my > > version. Then saving exif tags in jpeg came back to normal. > >What is your version? Could you produce a patch against CVS? I checkout from CVS before making those changes. I'm sending the=20 function attached. Just cut and paste. Regards, scuri ---------------------------------------------------------------- void exif_entry_initialize (ExifEntry *e, ExifTag tag) { time_t t; struct tm *tm; ExifRational r; ExifByteOrder o; /* We need the byte order */ if (!e || !e->parent || e->data || !e->parent->parent) return; o =3D exif_data_get_byte_order (e->parent->parent); e->tag =3D tag; switch (tag) { /* LONG, 1 component, no default */ case EXIF_TAG_PIXEL_X_DIMENSION: case EXIF_TAG_PIXEL_Y_DIMENSION: case EXIF_TAG_EXIF_IFD_POINTER: case EXIF_TAG_GPS_INFO_IFD_POINTER: case EXIF_TAG_INTEROPERABILITY_IFD_POINTER: case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: case EXIF_TAG_JPEG_INTERCHANGE_FORMAT: e->components =3D 1; e->format =3D EXIF_FORMAT_LONG; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); memset (e->data, 0, e->size); break; /* SHORT, 1 component, no default */ case EXIF_TAG_SUBJECT_LOCATION: case EXIF_TAG_SENSING_METHOD: case EXIF_TAG_PHOTOMETRIC_INTERPRETATION: case EXIF_TAG_COMPRESSION: case EXIF_TAG_EXPOSURE_MODE: case EXIF_TAG_WHITE_BALANCE: case EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM: case EXIF_TAG_GAIN_CONTROL: case EXIF_TAG_SUBJECT_DISTANCE_RANGE: case EXIF_TAG_FLASH: case EXIF_TAG_COLOR_SPACE: /* SHORT, 1 component, default 0 */ case EXIF_TAG_IMAGE_WIDTH: case EXIF_TAG_IMAGE_LENGTH: case EXIF_TAG_EXPOSURE_PROGRAM: case EXIF_TAG_LIGHT_SOURCE: case EXIF_TAG_METERING_MODE: case EXIF_TAG_CUSTOM_RENDERED: case EXIF_TAG_SCENE_CAPTURE_TYPE: case EXIF_TAG_CONTRAST: case EXIF_TAG_SATURATION: case EXIF_TAG_SHARPNESS: e->components =3D 1; e->format =3D EXIF_FORMAT_SHORT; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); exif_set_short (e->data, o, 0); break; /* SHORT, 1 component, default 1 */ case EXIF_TAG_ORIENTATION: case EXIF_TAG_PLANAR_CONFIGURATION: case EXIF_TAG_YCBCR_POSITIONING: e->components =3D 1; e->format =3D EXIF_FORMAT_SHORT; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); exif_set_short (e->data, o, 1); break; /* SHORT, 1 component, default 2 */ case EXIF_TAG_RESOLUTION_UNIT: case EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT: e->components =3D 1; e->format =3D EXIF_FORMAT_SHORT; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); exif_set_short (e->data, o, 2); break; /* SHORT, 1 component, default 3 */ case EXIF_TAG_SAMPLES_PER_PIXEL: e->components =3D 1; e->format =3D EXIF_FORMAT_SHORT; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); exif_set_short (e->data, o, 3); break; case EXIF_TAG_BITS_PER_SAMPLE: e->components =3D 3; e->format =3D EXIF_FORMAT_SHORT; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); exif_set_short (e->data, o, 8); exif_set_short ( e->data + exif_format_get_size (e->format), o, 8); exif_set_short ( e->data + 2 * exif_format_get_size (e->format), o, 8); break; case EXIF_TAG_YCBCR_SUB_SAMPLING: e->components =3D 2; e->format =3D EXIF_FORMAT_SHORT; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); exif_set_short (e->data, o, 2); exif_set_short ( e->data + exif_format_get_size (e->format), o, 1); break; /* SHORT, any component, no default */ case EXIF_TAG_SUBJECT_AREA: case EXIF_TAG_ISO_SPEED_RATINGS: e->components =3D 0; e->format =3D EXIF_FORMAT_SHORT; e->size =3D 0; e->data =3D 0; break; /* SRATIONAL, 1 component, no default */ case EXIF_TAG_EXPOSURE_BIAS_VALUE: case EXIF_TAG_BRIGHTNESS_VALUE: case EXIF_TAG_SHUTTER_SPEED_VALUE: e->components =3D 1; e->format =3D EXIF_FORMAT_SRATIONAL; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); memset (e->data, 0, e->size); break; /* RATIONAL, 1 component, no default */ case EXIF_TAG_EXPOSURE_TIME: case EXIF_TAG_FOCAL_PLANE_X_RESOLUTION: case EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION: case EXIF_TAG_EXPOSURE_INDEX: case EXIF_TAG_FLASH_ENERGY: case EXIF_TAG_FNUMBER: case EXIF_TAG_FOCAL_LENGTH: case EXIF_TAG_SUBJECT_DISTANCE: case EXIF_TAG_MAX_APERTURE_VALUE: case EXIF_TAG_APERTURE_VALUE: case EXIF_TAG_COMPRESSED_BITS_PER_PIXEL: case EXIF_TAG_PRIMARY_CHROMATICITIES: case EXIF_TAG_DIGITAL_ZOOM_RATIO: e->components =3D 1; e->format =3D EXIF_FORMAT_RATIONAL; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); memset (e->data, 0, e->size); break; /* RATIONAL, 1 component, default 72/1 */ case EXIF_TAG_X_RESOLUTION: case EXIF_TAG_Y_RESOLUTION: e->components =3D 1; e->format =3D EXIF_FORMAT_RATIONAL; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); r.numerator =3D 72; r.denominator =3D 1; exif_set_rational (e->data, o, r); break; /* RATIONAL, 2 components, no default */ case EXIF_TAG_WHITE_POINT: e->components =3D 2; e->format =3D EXIF_FORMAT_RATIONAL; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); memset (e->data, 0, e->size); break; /* RATIONAL, 6 components */ case EXIF_TAG_REFERENCE_BLACK_WHITE: e->components =3D 6; e->format =3D EXIF_FORMAT_RATIONAL; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); r.denominator =3D 1; r.numerator =3D 0; exif_set_rational (e->data, o, r); r.numerator =3D 255; exif_set_rational ( e->data + exif_format_get_size (e->format), o, r); r.numerator =3D 0; exif_set_rational ( e->data + 2 * exif_format_get_size (e->format), o,= r); r.numerator =3D 255; exif_set_rational ( e->data + 3 * exif_format_get_size (e->format), o,= r); r.numerator =3D 0; exif_set_rational ( e->data + 4 * exif_format_get_size (e->format), o,= r); r.numerator =3D 255; exif_set_rational ( e->data + 5 * exif_format_get_size (e->format), o,= r); break; /* EXIF_FORMAT_ASCII, 20 components, default current time */ case EXIF_TAG_DATE_TIME: case EXIF_TAG_DATE_TIME_ORIGINAL: case EXIF_TAG_DATE_TIME_DIGITIZED: t =3D time (NULL); tm =3D localtime (&t); e->components =3D 20; e->format =3D EXIF_FORMAT_ASCII; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); snprintf ((char *) e->data, e->size, "%04i:%02i:%02i %02i:%02i:%02i", tm->tm_year + 1900, tm->tm_mon,= tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); break; /* EXIF_FORMAT_ASCII, 13 components */ case EXIF_TAG_RELATED_SOUND_FILE: e->components =3D 13; e->format =3D EXIF_FORMAT_ASCII; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); break; case EXIF_TAG_IMAGE_UNIQUE_ID: e->components =3D 33; e->format =3D EXIF_FORMAT_ASCII; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); break; /* EXIF_FORMAT_ASCII, any components, no default */ case EXIF_TAG_SPECTRAL_SENSITIVITY: case EXIF_TAG_SUB_SEC_TIME: case EXIF_TAG_SUB_SEC_TIME_ORIGINAL: case EXIF_TAG_SUB_SEC_TIME_DIGITIZED: case EXIF_TAG_IMAGE_DESCRIPTION: case EXIF_TAG_MAKE: case EXIF_TAG_MODEL: case EXIF_TAG_SOFTWARE: case EXIF_TAG_ARTIST: case EXIF_TAG_COPYRIGHT: e->components =3D 0; e->format =3D EXIF_FORMAT_ASCII; e->size =3D 0; e->data =3D 0; break; /* UNDEFINED, any components, no default */ case=20 EXIF_TAG_OECF:=20 case EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE: case EXIF_TAG_NEW_CFA_PATTERN: case EXIF_TAG_DEVICE_SETTING_DESCRIPTION: case EXIF_TAG_MAKER_NOTE: case EXIF_TAG_USER_COMMENT: e->components =3D 0; e->format =3D EXIF_FORMAT_UNDEFINED; e->size =3D 0; e->data =3D 0; break; /* UNDEFINED, 1 component, default 1 */ case EXIF_TAG_SCENE_TYPE: e->components =3D 1; e->format =3D EXIF_FORMAT_UNDEFINED; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); e->data[0] =3D 0x01; break; /* UNDEFINED, 1 component, default 3 */ case EXIF_TAG_FILE_SOURCE: e->components =3D 1; e->format =3D EXIF_FORMAT_UNDEFINED; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); e->data[0] =3D 0x03; break; /* UNDEFINED, 4 components, default 0 1 0 0 */ case EXIF_TAG_FLASH_PIX_VERSION: e->components =3D 4; e->format =3D EXIF_FORMAT_UNDEFINED; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); memcpy (e->data, "0100", 4); break; /* UNDEFINED, 4 components, default 0 2 1 0 */ case EXIF_TAG_EXIF_VERSION: e->components =3D 4; e->format =3D EXIF_FORMAT_UNDEFINED; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); memcpy (e->data, "0210", 4); break; /* UNDEFINED, 4 components, no default */ case EXIF_TAG_COMPONENTS_CONFIGURATION: e->components =3D 4; e->format =3D EXIF_FORMAT_UNDEFINED; e->size =3D exif_format_get_size (e->format) *= e->components; e->data =3D malloc (e->size); break; default: break; } } ---------------------------------------------------------------- |
From: Lutz <lu...@us...> - 2004-05-03 19:04:07
|
On Mon, 2004-05-03 at 01:11, Antonio Scuri wrote: > Because this is very inefficient. The function exif_tag_get_name has a > loop looking for tag "i" every time is called. > Understood. You are perhaps looking for something like this: Index: exif-tag.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-tag.c,v retrieving revision 1.14 diff -u -3 -p -r1.14 exif-tag.c --- exif-tag.c 6 Aug 2003 19:47:53 -0000 1.14 +++ exif-tag.c 3 May 2004 19:00:58 -0000 @@ -571,6 +571,29 @@ static struct { {0, NULL, NULL, NULL} }; +/* For now, do not use these functions. */ +ExifTag exif_tag_table_get_tag (unsigned int n); +const char *exif_tag_table_get_name (unsigned int n); +unsigned int exif_tag_table_count (void); + +ExifTag +exif_tag_table_get_tag (unsigned int n) +{ + return (n < exif_tag_table_count ()) ? ExifTagTable[n].tag : 0; +} + +const char * +exif_tag_table_get_name (unsigned int n) +{ + return (n < exif_tag_table_count ()) ? ExifTagTable[n].name : NULL; +} + +unsigned int +exif_tag_table_count (void) +{ + return sizeof (ExifTagTable) / sizeof (ExifTagTable[0]); +} + const char * exif_tag_get_name (ExifTag tag) { > > > 5) I have to edit the function exif_entry_initialize from "exif-entry.c". > > > There are lots of uninitialized tags. I simply replace the function > > with my > > > version. Then saving exif tags in jpeg came back to normal. > > > >What is your version? Could you produce a patch against CVS? > > I checkout from CVS before making those changes. I'm sending the > function attached. Just cut and paste. I don't see where your version differs from the one in CVS. Regards Lutz |