/* See also vips_exif_to_s() ... keep in sync. */ static void vips_exif_from_s( ExifData *ed, ExifEntry *entry, const char *value ) { unsigned long i; const char *p; if( entry->format != EXIF_FORMAT_SHORT && entry->format != EXIF_FORMAT_SSHORT && entry->format != EXIF_FORMAT_LONG && entry->format != EXIF_FORMAT_SLONG && entry->format != EXIF_FORMAT_RATIONAL && entry->format != EXIF_FORMAT_SRATIONAL ) return; if( entry->components >= 10 ) return; /* Skip any leading spaces. */ p = value; while( *p == ' ' ) p += 1; for( i = 0; i < entry->components; i++ ) { if( entry->format == EXIF_FORMAT_SHORT || entry->format == EXIF_FORMAT_SSHORT || entry->format == EXIF_FORMAT_LONG || entry->format == EXIF_FORMAT_SLONG ) { int value = atof( p ); vips_exif_set_int( ed, entry, i, &value ); } else if( entry->format == EXIF_FORMAT_RATIONAL || entry->format == EXIF_FORMAT_SRATIONAL ) vips_exif_set_rational( ed, entry, i, (void *) p ); /* Skip to the next set of spaces, then to the beginning of * the next item. */ while( *p && *p != ' ' ) p += 1; while( *p == ' ' ) p += 1; if( !*p ) break; } }
/* See also vips_exif_to_s() ... keep in sync. Only the numeric types are * handled here, since they can be updated. For string types, we have to * destroy and recreate, see above. */ static void vips_exif_from_s( ExifData *ed, ExifEntry *entry, const char *value ) { unsigned long i; const char *p; int v; if( entry->format == EXIF_FORMAT_SHORT || entry->format == EXIF_FORMAT_SSHORT || entry->format == EXIF_FORMAT_LONG || entry->format == EXIF_FORMAT_SLONG ) { if( entry->components >= 10 ) return; p = value; for( i = 0; i < entry->components; i++ ) { if( !(p = skip_space( p )) ) break; v = atof( p ); vips_exif_set_int( ed, entry, i, &v ); p = skip_nonspace( p ); } } else if( entry->format == EXIF_FORMAT_RATIONAL || entry->format == EXIF_FORMAT_SRATIONAL ) { if( entry->components >= 10 ) return; p = value; for( i = 0; i < entry->components; i++ ) { if( !(p = skip_space( p )) ) break; vips_exif_set_rational( ed, entry, i, (void *) p ); p = skip_nonspace( p ); } } }