Exemple #1
0
 def test_doesnt_get_smaller_than_focal_point(self):
     "Test that the cropbox doesn't get any smaller than the focal point"
     self.assertEqual(
         crop_to_point((640, 480), (10, 10),
                       FocalPoint(x=320, y=240, width=100, height=100)),
         CropBox(270, 190, 370, 290),
     )
Exemple #2
0
 def test_keeps_composition(self):
     "Test that the cropbox tries to keep the composition of the original image as much as it can"
     self.assertEqual(
         crop_to_point((300, 300), (150, 150), FocalPoint(x=100, y=200)),
         CropBox(
             50, 100, 200,
             250),  # Focal point is 1/3 across and 2/3 down in the crop box
     )
Exemple #3
0
 def test_keeps_focal_point_in_view_bottom_left(self):
     """
     Even though it tries to keep the composition of the image,
     it shouldn't let that get in the way of keeping the entire subject in view
     """
     self.assertEqual(
         crop_to_point((300, 300), (150, 150), FocalPoint(x=100, y=200, width=150, height=150)),
         CropBox(25, 125, 175, 275),
     )
Exemple #4
0
 def test_doesnt_exit_bottom_right(self):
     "Test that the cropbox doesn't exit the image at the bottom right"
     self.assertEqual(
         crop_to_point((640, 480), (100, 100), FocalPoint(x=640, y=480)),
         CropBox(540, 380, 640, 480),
     )
Exemple #5
0
 def test_doesnt_exit_top_left(self):
     "Test that the cropbox doesn't exit the image at the top left"
     self.assertEqual(
         crop_to_point((640, 480), (100, 100), FocalPoint(x=0, y=0)),
         CropBox(0, 0, 100, 100),
     )
Exemple #6
0
 def test_basic_no_focal_point(self):
     "If focal point is None, it should make one in the centre of the image"
     self.assertEqual(
         crop_to_point((640, 480), (100, 100), None),
         CropBox(270, 190, 370, 290),
     )
Exemple #7
0
 def test_basic(self):
     "Test basic cropping in the centre of the image"
     self.assertEqual(
         crop_to_point((640, 480), (100, 100), FocalPoint(x=320, y=240)),
         CropBox(270, 190, 370, 290),
     )