src/Volume.php
public function detectFocalPoint(string $filePath): array
    {
        $extension = StringHelper::toLowerCase(pathinfo($filePath, PATHINFO_EXTENSION));

        if (!in_array($extension, ['jpeg', 'jpg', 'png'])) {
            return [];
        }


        $client = new RekognitionClient($this->_getConfigArray());
        $params = [
            'Image' => [
                'S3Object' => [
                    'Name' => $filePath,
                    'Bucket' => Craft::parseEnv($this->bucket),
                ],
            ],
        ];

        $faceData = $client->detectFaces($params);

        if (!empty($faceData['FaceDetails'])) {
            $face = array_shift($faceData['FaceDetails']);
            if ($face['Confidence'] > 80) {
                $box = $face['BoundingBox'];
                return [
                    number_format($box['Left'] + ($box['Width'] / 2), 4),
                    number_format($box['Top'] + ($box['Height'] / 2), 4),
                ];
            }
        }

        return [];
    }
public function detectFocalPoint(string $filePath): array
    {
        $extension = StringHelper::toLowerCase(pathinfo($filePath, PATHINFO_EXTENSION));

        if (!in_array($extension, ['jpeg', 'jpg', 'png'])) {
            return [];
        }


        $client = new RekognitionClient($this->_getConfigArray());
        $params = [
            'Image' => [
                'S3Object' => [
                    'Name' => $filePath,
                    'Bucket' => Craft::parseEnv($this->bucket),
                ],
            ],
        ];

        $faceData = $client->detectFaces($params);

        if (!empty($faceData['FaceDetails'])) {
            $face = array_shift($faceData['FaceDetails']);
            if ($face['Confidence'] > 80) {
                $box = $face['BoundingBox'];
                return [
                    number_format($box['Left'] + ($box['Width'] / 2), 4),
                    number_format($box['Top'] + ($box['Height'] / 2), 4),
                ];
            }
        }

        return [];
    }
public function detectFocalPoint ( string $ filePath ) : array { $ extension = StringHelper :: toLowerCase ( pathinfo ( $ filePath , PATHINFO_EXTENSION ) ) ; if ( ! in_array ( $ extension , [ 'jpeg' , 'jpg' , 'png' ] ) ) { return [ ] ; } $ client = new RekognitionClient ( $ this -> _getConfigArray ( ) ) ; $ params = [ 'Image' => [ 'S3Object' => [ 'Name' => $ filePath , 'Bucket' => Craft :: parseEnv ( $ this -> bucket ) , ] , ] , ] ; $ faceData = $ client -> detectFaces ( $ params ) ; if ( ! empty ( $ faceData [ 'FaceDetails' ] ) ) { $ face = array_shift ( $ faceData [ 'FaceDetails' ] ) ; if ( $ face [ 'Confidence' ] > 80 ) { $ box = $ face [ 'BoundingBox' ] ; return [ number_format ( $ box [ 'Left' ] + ( $ box [ 'Width' ] / 2 ) , 4 ) , number_format ( $ box [ 'Top' ] + ( $ box [ 'Height' ] / 2 ) , 4 ) , ] ; } } return [ ] ; }
Attempt to detect focal point for a path on the bucket and return the
focal point position as an array of decimal parts

@param string $filePath
@return array
Attempt to detect focal point for a path on the bucket and return the focal point position as an array of decimal parts