metadata was not being saved to vips files

broken by the rewind changes a few weeks ago

added a test too
This commit is contained in:
John Cupitt 2015-05-28 16:19:32 +01:00
parent 36331739ab
commit 98e80903e0
3 changed files with 41 additions and 3 deletions

18
TODO
View File

@ -1,3 +1,21 @@
- extra character in exif-data?
try:
$ cd test
$ vipsheader -a images/IMG_4618.jpg | grep exif-data
exif-data: VIPS_TYPE_BLOB, data = 0x16e0a20, length = 6626
$ vips copy images/IMG_4618.jpg x.v
$ vipsheader -a x.v | grep exif-data
exif-data: VIPS_TYPE_BLOB, data = 0x20679f0, length = 6627
one byte longer!
fix, and add a test for exif length to test/test_foreign.py
- how about something like vips_grid() which turns a tall thin one-band
image into a much smaller many-band image?

View File

@ -703,6 +703,9 @@ vips_image_generate( VipsImage *image,
VIPS_DEBUG_MSG( "vips_image_generate: "
"attaching partial callbacks\n" );
if( vips_image_written( image ) )
return( -1 );
break;
@ -742,6 +745,11 @@ vips_image_generate( VipsImage *image,
if( res )
return( -1 );
/* Must come before we rewind.
*/
if( vips_image_written( image ) )
return( -1 );
/* We've written to image ... rewind it ready for reading.
*/
if( vips_image_pio_input( image ) )
@ -759,8 +767,5 @@ vips_image_generate( VipsImage *image,
return( -1 );
}
if( vips_image_written( image ) )
return( -1 );
return( 0 );
}

View File

@ -104,6 +104,21 @@ class TestForeign(unittest.TestCase):
self.assertEqual(im.bands, x.bands)
self.assertLessEqual((im - x).abs().max(), max_diff)
def test_vips(self):
self.save_load_file("test.v", "", self.colour, 0)
# check we can save and restore metadata
self.colour.write_to_file("test.v")
x = Vips.Image.new_from_file("test.v")
before_exif = self.colour.get_value("exif-data")
after_exif = x.get_value("exif-data")
for i in range(len(before_exif)):
self.assertEqual(before_exif[i], after_exif[i])
x = None
os.unlink("test.v")
def test_jpeg(self):
x = Vips.type_find("VipsForeign", "jpegload")
if not x.is_instantiatable():