Moved extra room calculation into get_suggested_focal_point

pull/487/head
Karl Hobley 2014-07-21 15:53:27 +01:00
rodzic da3f48eba2
commit fe662b3ed6
2 zmienionych plików z 7 dodań i 6 usunięć

Wyświetl plik

@ -96,6 +96,11 @@ class AbstractImage(models.Model, TagSearchable):
feature_detector = FeatureDetector(image.size, image_mode, image_data)
focal_point = feature_detector.get_focal_point()
# Add 20% extra room around the edge of the focal point
if focal_point:
focal_point.width *= 1.20
focal_point.height *= 1.20
return focal_point
def get_rendition(self, filter, focal_point=None):

Wyświetl plik

@ -47,13 +47,9 @@ def crop_to_point(image_size, crop_size, focal_point):
if not focal_point:
focal_point = FocalPoint(original_width / 2, original_height / 2)
# Get size of focal point, add 15% extra to give some room around the edge
focal_point_width = focal_point.width * 1.15
focal_point_height = focal_point.height * 1.15
# Make sure that the crop size is no smaller than the focal point
crop_width = max(crop_width, focal_point_width)
crop_height = max(crop_height, focal_point_height)
crop_width = max(crop_width, focal_point.width)
crop_height = max(crop_height, focal_point.height)
# Make sure final dimensions do not exceed original dimensions
final_width = min(original_width, crop_width)