more exif read improvements
some jpegs use a signed long to store the resolution unit (??), remove the checks on tag format for res unit
This commit is contained in:
parent
74f545fc6f
commit
7025fe4081
@ -484,12 +484,11 @@ get_entry_double( ExifData *ed, int ifd, ExifTag tag, double *out )
|
||||
}
|
||||
|
||||
static int
|
||||
get_entry_short( ExifData *ed, int ifd, ExifTag tag, int *out )
|
||||
get_entry_int( ExifData *ed, int ifd, ExifTag tag, int *out )
|
||||
{
|
||||
ExifEntry *entry;
|
||||
|
||||
if( !(entry = exif_content_get_entry( ed->ifd[ifd], tag )) ||
|
||||
entry->format != EXIF_FORMAT_SHORT ||
|
||||
entry->components != 1 )
|
||||
return( -1 );
|
||||
|
||||
@ -507,7 +506,7 @@ set_vips_resolution( VipsImage *im, ExifData *ed )
|
||||
*/
|
||||
if( get_entry_double( ed, 0, EXIF_TAG_X_RESOLUTION, &xres ) ||
|
||||
get_entry_double( ed, 0, EXIF_TAG_Y_RESOLUTION, &yres ) ||
|
||||
get_entry_short( ed, 0, EXIF_TAG_RESOLUTION_UNIT, &unit ) ) {
|
||||
get_entry_int( ed, 0, EXIF_TAG_RESOLUTION_UNIT, &unit ) ) {
|
||||
vips_warn( "VipsJpeg",
|
||||
"%s", _( "error reading resolution" ) );
|
||||
return;
|
||||
|
@ -417,14 +417,12 @@ typedef void (*write_fn)( ExifData *ed,
|
||||
/* Write a tag. Update what's there, or make a new one.
|
||||
*/
|
||||
static int
|
||||
write_tag( ExifData *ed, int ifd,
|
||||
ExifTag tag, ExifFormat format, write_fn fn, void *data )
|
||||
write_tag( ExifData *ed, int ifd, ExifTag tag, write_fn fn, void *data )
|
||||
{
|
||||
ExifEntry *entry;
|
||||
|
||||
if( (entry = exif_content_get_entry( ed->ifd[ifd], tag )) ) {
|
||||
if( entry->format == format )
|
||||
fn( ed, entry, 0, data );
|
||||
fn( ed, entry, 0, data );
|
||||
}
|
||||
else {
|
||||
entry = exif_entry_new();
|
||||
@ -484,11 +482,11 @@ set_exif_resolution( ExifData *ed, VipsImage *im )
|
||||
/* Main image xres/yres/unit are in ifd0. ifd1 has the thumbnail
|
||||
* xres/yres/unit.
|
||||
*/
|
||||
if( write_tag( ed, 0, EXIF_TAG_X_RESOLUTION, EXIF_FORMAT_RATIONAL,
|
||||
if( write_tag( ed, 0, EXIF_TAG_X_RESOLUTION,
|
||||
vips_exif_set_double, (void *) &xres ) ||
|
||||
write_tag( ed, 0, EXIF_TAG_Y_RESOLUTION, EXIF_FORMAT_RATIONAL,
|
||||
write_tag( ed, 0, EXIF_TAG_Y_RESOLUTION,
|
||||
vips_exif_set_double, (void *) &yres ) ||
|
||||
write_tag( ed, 0, EXIF_TAG_RESOLUTION_UNIT, EXIF_FORMAT_SHORT,
|
||||
write_tag( ed, 0, EXIF_TAG_RESOLUTION_UNIT,
|
||||
vips_exif_set_int, (void *) &unit ) ) {
|
||||
vips_error( "VipsJpeg",
|
||||
"%s", _( "error setting JPEG resolution" ) );
|
||||
|
Loading…
Reference in New Issue
Block a user