FaceDetector.php
public function cropFaceToJpeg($outFileName = null)
    {
        if (empty($this->face)) {
            throw new NoFaceException('No face detected');
        }

        $canvas = imagecreatetruecolor($this->face['w'], $this->face['w']);
        imagecopy($canvas, $this->canvas, 0, 0, $this->face['x'], $this->face['y'], $this->face['w'], $this->face['w']);

        if ($outFileName === null) {
            header('Content-type: image/jpeg');
        }

        imagejpeg($canvas, $outFileName);
    }
public function cropFaceToJpeg($outFileName = null)
    {
        if (empty($this->face)) {
            throw new NoFaceException('No face detected');
        }

        $canvas = imagecreatetruecolor($this->face['w'], $this->face['w']);
        imagecopy($canvas, $this->canvas, 0, 0, $this->face['x'], $this->face['y'], $this->face['w'], $this->face['w']);

        if ($outFileName === null) {
            header('Content-type: image/jpeg');
        }

        imagejpeg($canvas, $outFileName);
    }
public function cropFaceToJpeg ( $ outFileName = null ) { if ( empty ( $ this -> face ) ) { throw new NoFaceException ( 'No face detected' ) ; } $ canvas = imagecreatetruecolor ( $ this -> face [ 'w' ] , $ this -> face [ 'w' ] ) ; imagecopy ( $ canvas , $ this -> canvas , 0 , 0 , $ this -> face [ 'x' ] , $ this -> face [ 'y' ] , $ this -> face [ 'w' ] , $ this -> face [ 'w' ] ) ; if ( $ outFileName === null ) { header ( 'Content-type: image/jpeg' ) ; } imagejpeg ( $ canvas , $ outFileName ) ; }
Crops the face from the photo.
Should be called after `faceDetect` function call
If file is provided, the face will be stored in file, other way it will be output to standard output.

@param string|null $outFileName file name to store. If null, will be printed to output

@throws NoFaceException
Crops the face from the photo . Should be called after faceDetect function call If file is provided the face will be stored in file other way it will be output to standard output .