PHP code example of leomarriel / laravel-face-detector

1. Go to this page and download the library: Download leomarriel/laravel-face-detector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leomarriel / laravel-face-detector example snippets


'providers' => [
  ...
  Leomarriel\FaceDetector\FaceDetectorServiceProvider::class,
  ...
],

use Leomarriel\FaceDetector\FaceDetector;

$face = new FaceDetector();
$face->loadFile('path/to/image.jpg');
$face->preview();

'aliases' => [
  ...
  'FaceDetector' => Leomarriel\FaceDetector\Facades\FaceDetector::class,
  ...
],

use FaceDetector;

$face = FaceDetector::loadFile('path/to/image.jpg')->preview();

use FaceDetector;

$face = FaceDetector::loadUrl('https://url/to/image.jpg')->preview();

use FaceDetector;

$face = FaceDetector::loadFile('path/to/image.jpg');

$face->found(); // (bool) Return a boolean whether or not a face was found in the file

$face->face(); // (array) Return an array with the position of the found face

$face->preview(); // Return a preview of the face found with a tag

$face->json(); // Return the found face in json format

$face->stream(); // Return a response with found face cropped in JPG to show in browser

$face->output(); // Return a jpg string file with the found face

$face->save(); // Physically save the face found

$face->save(); // Physically save the face found on folder "facedetector" in your storage

$face->save('path/to/save'); // Physically save the found face with a random name in a defined path.

$face->save('path/to/save', 'new-image.jpg'); // Physically save the found face with a defined path and name.

[
    'filename' => 'Saved file name',
    'size' => 'file size after cropping',
    'path' => 'path to file location relative to the disk storage',
    'url' => 'public url to access the file in browser'
]

php artisan vendor:publish --tag=facedetector-config