add more thumbnail tests
esp. the new force mode
This commit is contained in:
parent
8e7a00105f
commit
2f6f2b93ef
@ -729,7 +729,7 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
|
||||
* Optional arguments:
|
||||
*
|
||||
* * @height: %gint, target height in pixels
|
||||
* * @size: #VipsSize, upsize, downsize or both
|
||||
* * @size: #VipsSize, upsize, downsize, both or force
|
||||
* * @auto_rotate: %gboolean, rotate upright using orientation tag
|
||||
* * @crop: #VipsInteresting, shrink and crop to fill target
|
||||
* * @linear: %gboolean, perform shrink in linear light
|
||||
@ -766,7 +766,7 @@ vips_thumbnail_file_init( VipsThumbnailFile *file )
|
||||
* these tags will not be interpreted.
|
||||
*
|
||||
* Shrinking is normally done in sRGB colourspace. Set @linear to shrink in
|
||||
* linear light colourspace instead --- this can give better results, but can
|
||||
* linear light colourspace instead. This can give better results, but can
|
||||
* also be far slower, since tricks like JPEG shrink-on-load cannot be used in
|
||||
* linear space.
|
||||
*
|
||||
@ -901,7 +901,7 @@ vips_thumbnail_buffer_init( VipsThumbnailBuffer *buffer )
|
||||
* Optional arguments:
|
||||
*
|
||||
* * @height: %gint, target height in pixels
|
||||
* * @size: #VipsSize, upsize, downsize or both
|
||||
* * @size: #VipsSize, upsize, downsize, both or force
|
||||
* * @auto_rotate: %gboolean, rotate upright using orientation tag
|
||||
* * @crop: #VipsInteresting, shrink and crop to fill target
|
||||
* * @linear: %gboolean, perform shrink in linear light
|
||||
|
BIN
test/images/Landscape_6.jpg
Normal file
BIN
test/images/Landscape_6.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 127 KiB |
@ -107,6 +107,7 @@ class TestResample(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.jpeg_file = "images/йцук.jpg"
|
||||
self.rotated_jpeg_file = "images/Landscape_6.jpg"
|
||||
|
||||
def test_affine(self):
|
||||
im = Vips.Image.new_from_file(self.jpeg_file)
|
||||
@ -216,12 +217,38 @@ class TestResample(unittest.TestCase):
|
||||
self.assertNotEqual(im.width, 300)
|
||||
self.assertEqual(im.height, 100)
|
||||
|
||||
# with @crop, should fit both width and height
|
||||
im = Vips.Image.thumbnail(self.jpeg_file, 100,
|
||||
height = 300, crop = True)
|
||||
# force should fit width and height ... although this jpg has an
|
||||
# orientation tag, we ignore it unless autorot is on
|
||||
im = Vips.Image.thumbnail(self.rotated_jpeg_file, 100, height = 300,
|
||||
size = "force")
|
||||
self.assertEqual(im.width, 100)
|
||||
self.assertEqual(im.height, 300)
|
||||
|
||||
# with force + autorot, we spin the image, but the output size should
|
||||
# not change
|
||||
im = Vips.Image.thumbnail(self.rotated_jpeg_file, 100, height = 300,
|
||||
size = "force", auto_rotate = True)
|
||||
self.assertEqual(im.width, 100)
|
||||
self.assertEqual(im.height, 300)
|
||||
|
||||
# with @crop, should fit both width and height
|
||||
im = Vips.Image.thumbnail(self.jpeg_file, 100,
|
||||
height = 300, crop = "centre")
|
||||
self.assertEqual(im.width, 100)
|
||||
self.assertEqual(im.height, 300)
|
||||
|
||||
# with size up, should not downsize
|
||||
im = Vips.Image.thumbnail(self.jpeg_file, 100, size = "up")
|
||||
self.assertEqual(im.width, im_orig.width)
|
||||
im = Vips.Image.thumbnail(self.jpeg_file, 10000, size = "up")
|
||||
self.assertEqual(im.width, 10000)
|
||||
|
||||
# with size down, should not upsize
|
||||
im = Vips.Image.thumbnail(self.jpeg_file, 100, size = "down")
|
||||
self.assertEqual(im.width, 100)
|
||||
im = Vips.Image.thumbnail(self.jpeg_file, 10000, size = "down")
|
||||
self.assertEqual(im.width, im_orig.width)
|
||||
|
||||
im1 = Vips.Image.thumbnail(self.jpeg_file, 100)
|
||||
with open(self.jpeg_file, 'rb') as f:
|
||||
buf = f.read()
|
||||
|
Loading…
x
Reference in New Issue
Block a user