private function scoreLocalImages($locallyStoredImages): array {
        $results = [];
        $i = 1;
        $initialArea = 0;

        // Limit to the first 30 images
        $locallyStoredImages = array_slice($locallyStoredImages, 0, 30);

        foreach ($locallyStoredImages as $locallyStoredImage) {
            $sequenceScore = 1 / $i;
            $area = $locallyStoredImage->getWidth() * $locallyStoredImage->getHeight();

            if ($initialArea == 0) {
                $initialArea = $area * 1.48;
                $totalScore = 1;
            } else {
                $areaDifference = $area * $initialArea;
                $totalScore = $sequenceScore * $areaDifference;
            }

            $i++;

            $results[$totalScore] = $locallyStoredImage;
        }

        return $results;
    }
private function scoreLocalImages($locallyStoredImages): array {
        $results = [];
        $i = 1;
        $initialArea = 0;

        // Limit to the first 30 images
        $locallyStoredImages = array_slice($locallyStoredImages, 0, 30);

        foreach ($locallyStoredImages as $locallyStoredImage) {
            $sequenceScore = 1 / $i;
            $area = $locallyStoredImage->getWidth() * $locallyStoredImage->getHeight();

            if ($initialArea == 0) {
                $initialArea = $area * 1.48;
                $totalScore = 1;
            } else {
                $areaDifference = $area * $initialArea;
                $totalScore = $sequenceScore * $areaDifference;
            }

            $i++;

            $results[$totalScore] = $locallyStoredImage;
        }

        return $results;
    }
private function scoreLocalImages ( $ locallyStoredImages ) : array { $ results = [ ] ; $ i = 1 ; $ initialArea = 0 ; // Limit to the first 30 images $ locallyStoredImages = array_slice ( $ locallyStoredImages , 0 , 30 ) ; foreach ( $ locallyStoredImages as $ locallyStoredImage ) { $ sequenceScore = 1 / $ i ; $ area = $ locallyStoredImage -> getWidth ( ) * $ locallyStoredImage -> getHeight ( ) ; if ( $ initialArea == 0 ) { $ initialArea = $ area * 1.48 ; $ totalScore = 1 ; } else { $ areaDifference = $ area * $ initialArea ; $ totalScore = $ sequenceScore * $ areaDifference ; } $ i ++ ; $ results [ $ totalScore ] = $ locallyStoredImage ; } return $ results ; }
Set image score and on locally downloaded images

we're going to score the images in the order in which they appear so images higher up will have more importance,
we'll count the area of the 1st image as a score of 1 and then calculate how much larger or small each image after it is
we'll also make sure to try and weed out banner type ad blocks that have big widths and small heights or vice versa
so if the image is 3rd found in the dom it's sequence score would be 1 / 3 = .33 * diff in area from the first image

@param LocallyStoredImage[] $locallyStoredImages

@return LocallyStoredImage[]
Set image score and on locally downloaded images