R% ';
exit;
}
else {
header('Content-Type: image/svg+xml');
echo '';
exit;
}
}
if (!empty($_POST['filedata'])) {
// The data needs to start with a valid PNG header, encoded in base64
$filedata = $_POST['filedata'];
if (!str_starts_with($filedata, "iVBORw0KGgoAAAANSUhEUg")) {
die('Invalid image header');
}
$data = base64_decode($_POST['filedata']);
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w"),
);
// Convert the image to the right size
$process = proc_open("convert png:- -resize 256x256 png:-", $descriptorspec, $pipes, '.', array());
if (!is_resource($process)) {
die('Internal Server Error with proc_open');
}
fwrite($pipes[0], $data);
fclose($pipes[0]);
header('Content-Type: image/png');
echo stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
exit;
}
?>
Create your own NFT gallery!
Create your own NFT gallery!
Before creating your gallery, your image needs to be of the right size. Use this service to resize it!