mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Moved extra room calculation into get_suggested_focal_point
This commit is contained in:
parent
da3f48eba2
commit
fe662b3ed6
@ -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):
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user