The original algorithm implemented in the Smart Crop effects has a limitation: its results are dependent on the size of the crop area, since the algorithm finds the 'slice with the crop size' of the image that has the most entropy. This issue is implementing an alternative algorithm, that is keeping the part of the source image within the crop window, applying a grid to the source image and determining a subgrid that has the most entropy, then iterating until the grid window is smaller than the crop area. This keeps the entropy centroid of the source image always in the crop independently from the crop size.

The two algorithms in comparison, starting from the core balloons image, and applying a Smart Crop effect for a progressively smaller % width crop:

Smart Crop - Width % Image entropy - slicing Image entropy - recursive grid
Full image
70%
60%
50%
40%
30%
20%
10%
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Status: Active » Needs review
FileSize
52.11 KB

Patch.

mondrake’s picture

FileSize
50.98 KB

Removed TravisCI hunk.

The last submitted patch, 3: 3023305-3.patch, failed testing. View results

mondrake’s picture

FileSize
51.56 KB
26.98 KB

PHPCS fixes.

  • mondrake committed c91551c on 8.x-1.x
    Issue #3023305 by mondrake: Alternative algorithm for Smart Crop
    

  • mondrake committed a6d9d2e on 8.x-2.x
    Issue #3023305 by mondrake: Alternative algorithm for Smart Crop
    
mondrake’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.