fix shrink with non-int args
fix a silly bug, add a test
This commit is contained in:
parent
d126a733a0
commit
30a3d2f7fa
2
TODO
2
TODO
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
test with ~/Desktop/OHHFN.png
|
test with ~/Desktop/OHHFN.png
|
||||||
|
|
||||||
- add a test suite test for vips_shrink with non-int args
|
|
||||||
|
|
||||||
- we have Vips.leak_set() and Vips.cache_set_trace() ... stupid! make
|
- we have Vips.leak_set() and Vips.cache_set_trace() ... stupid! make
|
||||||
everything Vips.set_thing()
|
everything Vips.set_thing()
|
||||||
|
|
||||||
|
@ -95,16 +95,17 @@ vips_shrink_build( VipsObject *object )
|
|||||||
vips_shrinkh( t[0], &t[1], xshrink_int, NULL ) )
|
vips_shrinkh( t[0], &t[1], xshrink_int, NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
xresidual = target_width / t[1]->Xsize;
|
xresidual = (double) target_width / t[1]->Xsize;
|
||||||
yresidual = target_height / t[1]->Ysize;
|
yresidual = (double) target_height / t[1]->Ysize;
|
||||||
|
|
||||||
if( vips_affine( t[1], &t[2],
|
if( vips_affine( t[1], &t[2],
|
||||||
xresidual, 0, 0, yresidual, NULL ) ||
|
xresidual, 0.0, 0.0, yresidual, NULL ) ||
|
||||||
vips_image_write( t[2], resample->out ) )
|
vips_image_write( t[2], resample->out ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( vips_shrinkv( resample->in, &t[0], shrink->yshrink, NULL ) ||
|
if( vips_shrinkv( resample->in, &t[0],
|
||||||
|
shrink->yshrink, NULL ) ||
|
||||||
vips_shrinkh( t[0], &t[1], shrink->xshrink, NULL ) ||
|
vips_shrinkh( t[0], &t[1], shrink->xshrink, NULL ) ||
|
||||||
vips_image_write( t[1], resample->out ) )
|
vips_image_write( t[1], resample->out ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
@ -58,6 +58,12 @@ class TestResample(unittest.TestCase):
|
|||||||
im2 = im.shrink(4, 4)
|
im2 = im.shrink(4, 4)
|
||||||
self.assertEqual(im2.width, im.width // 4)
|
self.assertEqual(im2.width, im.width // 4)
|
||||||
self.assertEqual(im2.height, im.height // 4)
|
self.assertEqual(im2.height, im.height // 4)
|
||||||
|
self.assertTrue(abs(im.avg() - im2.avg()) < 1)
|
||||||
|
|
||||||
|
im2 = im.shrink(2.5, 2.5)
|
||||||
|
self.assertEqual(im2.width, im.width // 2.5)
|
||||||
|
self.assertEqual(im2.height, im.height // 2.5)
|
||||||
|
self.assertTrue(abs(im.avg() - im2.avg()) < 1)
|
||||||
|
|
||||||
def test_similarity(self):
|
def test_similarity(self):
|
||||||
im = Vips.Image.new_from_file("images/IMG_4618.jpg")
|
im = Vips.Image.new_from_file("images/IMG_4618.jpg")
|
||||||
|
Loading…
Reference in New Issue
Block a user