{"id":19746338,"url":"https://github.com/symisc/pixlab-php","last_synced_at":"2025-06-16T16:07:11.863Z","repository":{"id":57063770,"uuid":"89976192","full_name":"symisc/pixlab-php","owner":"symisc","description":"Official PHP Client for the PixLab Machine Vision API","archived":false,"fork":false,"pushed_at":"2023-10-09T01:50:45.000Z","size":24,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-24T18:04:43.525Z","etag":null,"topics":["api","client","computer-vision","machine-learning","php-library","pixlab"],"latest_commit_sha":null,"homepage":"https://pixlab.io/start","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/symisc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-02T00:54:52.000Z","updated_at":"2024-06-17T14:04:08.000Z","dependencies_parsed_at":"2022-08-24T10:10:33.933Z","dependency_job_id":null,"html_url":"https://github.com/symisc/pixlab-php","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symisc%2Fpixlab-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symisc%2Fpixlab-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symisc%2Fpixlab-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symisc%2Fpixlab-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/symisc","download_url":"https://codeload.github.com/symisc/pixlab-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224202823,"owners_count":17272807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","computer-vision","machine-learning","php-library","pixlab"],"created_at":"2024-11-12T02:14:19.820Z","updated_at":"2024-11-12T02:14:20.413Z","avatar_url":"https://github.com/symisc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PixLab Machine Vision APIs - Official PHP Client \n[![GitHub package version](https://img.shields.io/badge/Packagist-Ready-green.svg)](https://packagist.org/packages/symisc/pixlab-php)\n\nThis is the official PixLab PHP Client for the [PixLab](https://pixlab.io) Machine Vision API. The client is a single PHP class which let you interact with the API server using the GET and POST HTTP methods.\n\nFor the full list of samples using this class, please refer to: \n* [PHP Code Samples](https://github.com/symisc/pixlab/tree/master/PHP)\n* [PixLab Examples Page](https://pixlab.io/examples)\n* [Implement a Minimalistic KYC Form \u0026 Identify Verification Check ](https://dev.to/unqlite_db/implement-a-minimalistic-kyc-form-identify-verification-check-36f5)\n* [Step-by-step guide to do e-KYC in your app](https://itnext.io/step-by-step-guide-to-do-e-kyc-in-your-app-c3b4e240617)\n* [Scanning Malaysian, UAE, India \u0026 Others ID Cards with PixLab API](https://levelup.gitconnected.com/scanning-malaysian-id-cards-with-pixlab-api-33dd527a9408)\n## Example: Scan Passports, Visas or ID cards from various countries:\n```php\nrequire_once \"pixlab.php\";\n\n# Given a government issued passport document, extract the user face and parse all MRZ fields.\n#\n# PixLab recommend that you connect your AWS S3 bucket via your dashboard at https://pixlab.io/dashboard\n# so that any cropped face or MRZ crop is stored automatically on your S3 bucket rather than the PixLab one.\n# This feature should give you full control over your analyzed media files.\n#\n# https://pixlab.io/cmd?id=docscan for additional information.\n\n/* Passport prototype: Of course, replace with a real government issued passport if you \n * want to deal with a real world situation.\n */\n$passport = 'https://i.stack.imgur.com/oJY2K.png';\n\n# Your PixLab key\n$key = 'PIXLAB_API_KEY';\n\n/* Process */\n$pix = new Pixlab($key);\nif( !$pix-\u003eget('docscan',[\n\t'img' =\u003e $passport,  /* Passport scanned image */ \n\t'type' =\u003e 'passport' /* Type of document we are going to scan */ \n\t]) ){\n\techo $pix-\u003eget_error_message().\"\\n\";\n\tdie;\n}\n/* Output the scan result */\necho \"User Cropped Face: \" . $pix-\u003ejson-\u003eface_url . \"\\n\";\necho \"MRZ Cropped Image: \" . $pix-\u003ejson-\u003emrz_img_url . \"\\n\";\necho \"Raw MRZ Text: \" . $pix-\u003ejson-\u003emrz_raw_text . \"\\n\";\necho \"MRZ Fields:\\n\";\n/* Display all parsed MRZ fields */\necho \"\\tIssuing Country: \" . $pix-\u003ejson-\u003efields-\u003eissuingCountry . \"\\n\";\necho \"\\tFull Name: \"       . $pix-\u003ejson-\u003efields-\u003efullName . \"\\n\";\necho \"\\tDocument Number: \" . $pix-\u003ejson-\u003efields-\u003edocumentNumber  . \"\\n\";\necho \"\\tCheck Digit: \"   . $pix-\u003ejson-\u003efields-\u003echeckDigit . \"\\n\";\necho \"\\tNationality: \"   . $pix-\u003ejson-\u003efields-\u003enationality . \"\\n\";\necho \"\\tDate Of Birth: \" . $pix-\u003ejson-\u003efields-\u003edateOfBirth . \"\\n\";\necho \"\\tSex: \"           . $pix-\u003ejson-\u003efields-\u003esex . \"\\n\";\necho \"\\tDate Of Expiry: \"    . $pix-\u003ejson-\u003efields-\u003edateOfExpiry . \"\\n\";\necho \"\\tPersonal Number: \"   . $pix-\u003ejson-\u003efields-\u003epersonalNumber . \"\\n\";\necho \"\\tFinal Check Digit: \" . $pix-\u003ejson-\u003efields-\u003efinalcheckDigit . \"\\n\";\n```\n\n## First Example: Blur all human faces:\n```php\nrequire_once \"pixlab.php\";\n\n/*\n * Detect all human faces in a given image or video frame via `facedetect` and blur all of them via `mogrify`.\n * https://pixlab.io/#/cmd?id=facedetect \u0026 https://pixlab.io/#/cmd?id=mogrify for additional information.\n */\n \n# Target Image: Feel free to change to whatever image holding faces you want\n$img = 'http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg';\n\n$key = 'My_Pix_Key';\n\n$pix = new Pixlab($key);\necho \"Detecting faces first...\\n\";\n/* Invoke facedetect first  */\nif( !$pix-\u003eget('facedetect',array('img' =\u003e $img)) ){\n\techo $pix-\u003eget_error_message();\n\tdie;\n}\n/* Grab the total number of detected faces */\n$faces = $pix-\u003ejson-\u003efaces;\n\n\nif( count($faces) \u003c 1 ){\n\techo \"No human faces were were detected on this picture\\n\";\n}else{\n\techo \"Total number of detected faces: \".count($faces).\"\\n\";\n\techo \"Censuring faces...\\n\";\n\t/* Call mogrify (Only POST) */\n\tif( !$pix-\u003epost('mogrify',array('img' =\u003e $img,'cord' =\u003e $faces)) ){\n\t\techo $pix-\u003eget_error_message();\n\t}else{\n\t\techo \"Censured Faces: \".$pix-\u003ejson-\u003elink.\"\\n\";\n\t}\n}\n```\n## Second Example: Mimic Snapchat Filters\n```php\n/*\n * PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github\n * https://github.com/symisc/pixlab-php \n */\nrequire_once \"pixlab.php\";\n\n# Detect all human faces \u0026 extract their landmark regions via facelandmarks \u0026 make a small Snapchat filter effect.\n# Only three commands are actually needed in order to mimic the Snapchat filters effects:\n# face landmarks:         https://pixlab.io/#/cmd?id=facelandmarks\n# smart resize:           https://pixlab.io/#/cmd?id=smartresize\n# merge:                  https://pixlab.io/#/cmd?id=merge\n# Optionally: blur, grayscale, oilpaint, etc. for cool background effects.\n\n$img = 'http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg';\n\n$pix = new Pixlab('My_Pix_Key');\n/* Grab the face landmarks first */\nif( !$pix-\u003eget('facelandmarks',[\n\t'img' =\u003e $img\n\t]) ){\n\techo $pix-\u003eget_error_message().\"\\n\";\n\tdie;\n}\n\n$total = count($pix-\u003ejson-\u003efaces); # Total detected faces\nprint($total.\" faces were detected\\n\");\n$snap = [];\n# Iterate all over the detected faces\nforeach ($pix-\u003ejson-\u003efaces as $face){\n\t$cord = $face-\u003erectangle;\n\t# Show the face coordinates \n\tprint (\"Coordinates...\\n\");\n\tprint (\"\\n\\twidth: \" . $cord-\u003ewidth . ' height: ' . $cord-\u003eheight . ' x: ' . $cord-\u003eleft .' y: ' . $cord-\u003etop);\n\t\n\t# Show landmarks:\n\tprint (\"\\nLandmarks...\\n\");\n\t\n\t$landmarks = $face-\u003elandmarks;\n\t\n\tprint (\"\\n\\tNose: X: \"       . $landmarks-\u003enose-\u003ex      . \", Y: \".$landmarks-\u003enose-\u003ey);\n\tprint (\"\\n\\tBottom Lip: X: \" . $landmarks-\u003ebottom_lip-\u003ex. \", Y: \".$landmarks-\u003ebottom_lip-\u003ey);\n\tprint (\"\\n\\tTop Lip: X: \"    . $landmarks-\u003etop_lip-\u003ex   . \", Y: \".$landmarks-\u003etop_lip-\u003ey);\n\tprint (\"\\n\\tChin: X: \"       . $landmarks-\u003echin-\u003ex      . \", Y: \".$landmarks-\u003echin-\u003ey);\n\t\n\tprint (\"\\n\\tBone Center: X: \"     . $landmarks-\u003ebone-\u003ecenter-\u003ex     . \", Y: \".$landmarks-\u003ebone-\u003ecenter-\u003ey);\n\tprint (\"\\n\\tBone Outer Left: X: \" . $landmarks-\u003ebone-\u003eouter_left-\u003ex . \", Y: \".$landmarks-\u003ebone-\u003eouter_left-\u003ey);\n\tprint (\"\\n\\tBone Outer Right: X: \". $landmarks-\u003ebone-\u003eouter_right-\u003ex. \", Y: \".$landmarks-\u003ebone-\u003eouter_right-\u003ey);\n\t\n\tprint (\"\\n\\tBone Center: X: \" . $landmarks-\u003ebone-\u003ecenter-\u003ex . \", Y: \".$landmarks-\u003ebone-\u003ecenter-\u003ey);\n\t\n\tprint (\"\\n\\tEye Pupil Left: X: \" . $landmarks-\u003eeye-\u003epupil_left-\u003ex . \", Y: \".$landmarks-\u003eeye-\u003epupil_left-\u003ey);\n\tprint (\"\\n\\tEye Pupil Right: X: \" . $landmarks-\u003eeye-\u003epupil_right-\u003ex . \", Y: \".$landmarks-\u003eeye-\u003epupil_right-\u003ey);\n\t\n\tprint (\"\\n\\tEye Left Brown Inner: X: \" . $landmarks-\u003eeye-\u003eleft_brow_inner-\u003ex . \", Y: \".$landmarks-\u003eeye-\u003eleft_brow_inner-\u003ey);\n\tprint (\"\\n\\tEye Right Brown Inner: X: \" . $landmarks-\u003eeye-\u003eright_brow_inner-\u003ex . \", Y: \".$landmarks-\u003eeye-\u003eright_brow_inner-\u003ey);\n\t\n\tprint (\"\\n\\tEye Left Outer: X: \" . $landmarks-\u003eeye-\u003eleft_outer-\u003ex . \", Y: \".$landmarks-\u003eeye-\u003eleft_outer-\u003ey);\n\tprint (\"\\n\\tEye Right Outer: X: \" . $landmarks-\u003eeye-\u003eright_outer-\u003ex . \", Y: \".$landmarks-\u003eeye-\u003eright_outer-\u003ey); \n\t\n\t# More landmarks on the docs..\n\t\n\t# Pick the last face in this loop for the sack of simplicity. Refer to the sample set for a complete example\n\t$snap = $face;\n}\n# Make a quick Snapchat filter on top of the last detected face\nif ($total \u003c 1){\n    # No faces were detected\n\tdie;\n}\n \n# The flower crown to be composited on top of the target face\n$flower = 'http://pixlab.xyz/images/flower_crown.png';\n\n# Resize the flower crown which is quite big right now to exactly the face width using smart resize.\nprint (\"\\nResizing the snap flower crown...\\n\");\nif( !$pix-\u003eget('smartresize',[\n\t'img' =\u003e $flower,\n\t'width' =\u003e 20 + $snap-\u003erectangle-\u003ewidth, # Face width\n\t'height' =\u003e 0 # Let Pixlab decide the best height for this picture\n\t]) ){\n\techo $pix-\u003eget_error_message().\"\\n\";\n}else{\n\t$flower = $pix-\u003ejson-\u003elink;\n}\n# Finally, Perform the composite operation\nprint (\"Composite operation...\\n\");\nif( !$pix-\u003epost('merge',[\n\t'src' =\u003e $img,\n\t'cord' =\u003e [\n\tarray( /* Array for each landmarks */\n\t\t'img' =\u003e $flower,\n\t\t'x' =\u003e $snap-\u003elandmarks-\u003ebone-\u003eouter_left-\u003ex,\n\t\t'y' =\u003e $snap-\u003elandmarks-\u003ebone-\u003eouter_left-\u003ey /* Adjust for optimal effect */\n\t)\n\t]]) ){\n\techo $pix-\u003eget_error_message();\n}else{\n\t # Optionally call blur, oilpaint, grayscale for more stuff..\n\tprint (\"Snap Filter Effect: \".$pix-\u003ejson-\u003elink);\n}\necho \"\\n\";\n```\n## Third example: Blur an image or video frame based on its NSFW score\n```php\nrequire_once \"pixlab.php\";\n\n# Target Image: Change to any link (Possibly adult) you want or switch to POST if you want to upload your image directly.\n# The target API endpoint we'll be using here: nsfw (https://pixlab.io/cmd?id=nsfw).\n$img = 'https://i.redd.it/oetdn9wc13by.jpg';\n\n# Your PixLab key\n$key = 'My_Pixlab_Key';\n\n# Blur an image based on its NSFW score\n$pix = new Pixlab($key);\n/* Invoke NSFW */\nif( !$pix-\u003eget('nsfw',array('img' =\u003e $img)) ){\n\techo $pix-\u003eget_error_message();\n\tdie;\n}\n/* Grab the NSFW score */\n$score = $pix-\u003ejson-\u003escore;\nif( $score \u003c 0.5 ){\n\techo \"No adult content were detected on this picture\\n\";\n}else{\n\techo \"Censuring NSFW picture...\\n\";\n\t/* Call blur with the highest possible radius and sigma */\n\tif( !$pix-\u003eget('blur',array('img' =\u003e $img,'rad' =\u003e 50,'sig' =\u003e30)) ){\n\t\techo $pix-\u003eget_error_message();\n\t}else{\n\t\techo \"Censured Picture: \".$pix-\u003ejson-\u003elink.\"\\n\";\n\t}\n}\n?\u003e\n```\n### Last example:  Detect input language \u0026 extract text content from there using PixLab OCR.\n```php\n/*\n * PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github\n * https://github.com/symisc/pixlab-php \n */\nrequire_once \"pixlab.php\";\n\n# Given an image with human readable characters. Detect input language \u0026 extract text content from there.\n# https://pixlab.io/#/cmd?id=ocr for additional information.\n\n/* Target image with human readable text input */\n$img = 'http://quotesten.com/wp-content/uploads/2016/06/Confucius-Quote.jpg';\n\n# Your PixLab key\n$key = 'My_PixLab_Key';\n\n/* Process */\n$pix = new Pixlab($key);\nif( !$pix-\u003eget('ocr',array('img' =\u003e $img)) ){\n\techo $pix-\u003eget_error_message().\"\\n\";\n\tdie;\n}\necho \"Input language: \".$pix-\u003ejson-\u003elang;\necho \"\\nText Output: \".$pix-\u003ejson-\u003eoutput.\"\\n\";\n\n```\n## Useful Links\n* [The PixLab API in 5 minutes or less](https://pixlab.io/start).\n* [List of API endpoints](https://pixlab.io/api).\n* [The PixLab API Reference Guide](https://pixlab.io/cmdls).\n* [The PixLab Sample Set](https://pixlab.io/examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymisc%2Fpixlab-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymisc%2Fpixlab-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymisc%2Fpixlab-php/lists"}