Skip to content

Instantly share code, notes, and snippets.

@symisc
Last active March 31, 2021 01:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save symisc/b0c1ad7fdc8a5d9b2b7693b3cd82b97e to your computer and use it in GitHub Desktop.
Save symisc/b0c1ad7fdc8a5d9b2b7693b3cd82b97e to your computer and use it in GitHub Desktop.
Convert a given image to the grayscale color space using the PixLab API - https://pixlab.io/cmd?id=grayscale
<?php
/*
* PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github
* https://github.com/symisc/pixlab-php
*/
require_once "pixlab.php";
/*
* Convert a given image to gray color model. A grayscale (or graylevel) image is simply one in which the only colors are shades of gray.
* https://pixlab.io/cmd?id=grayscale for additional information.
*/
# Your PixLab key
$key = 'PIXLAB_API_KEY'; # Your PixLab API Key - Get your from https://pixlab.io/dashboard
$pix = new Pixlab($key);
if( !$pix->get('grayscale',array('img' => 'https://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg')) ){
echo $pix->get_error_message();
die;
}
echo "Pic Link: ".$pix->json->link."\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment