Skip to content

Instantly share code, notes, and snippets.

@symisc
Last active September 21, 2021 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save symisc/b3498b9c616ac78d9fa84fbe57afc385 to your computer and use it in GitHub Desktop.
Save symisc/b3498b9c616ac78d9fa84fbe57afc385 to your computer and use it in GitHub Desktop.
Dynamically generates a set of random pixels of desired width & height using PixLab /pixelgenerate API endpoint - https://pixlab.io/cmd?id=pixelgenerate
<?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";
# Generates a set of random pixels of desired Width & Height.
# This endpoint is similar to the /newimage endpoint except that the image contents is filled with random pixels.
# This is very useful for generating background (negative) samples for feeding Machine Learning training algorithms.
# https://pixlab.io/cmd?id=pixelgenerate for additional information.
# Your PixLab API key
$key = 'MY_PIXLAB_API_KEY'; # Get yours from https://console.pixlab.io/
# Randomly generate the Pixel
$pix = new Pixlab($key);
if( !$pix->get('pixelgenerate',[
"width" => 300,
"height" => 300
]) ){
echo $pix->get_error_message()."\n";
die;
}
echo "Randomly generated Image: ".$pix->json->ssl_link."\n";
@symisc
Copy link
Author

symisc commented Sep 21, 2021

Generates a set of random pixels of desired Width & Height.
This endpoint is similar to the /newimage endpoint except that the image contents is filled with random pixels.
This is very useful for generating background (negative) samples for feeding Machine Learning training algorithms.

https://pixlab.io/cmd?id=pixelgenerate for additional information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment