Last active
September 21, 2021 01:52
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.