Repositories | Polyback | Log in to see private repositories


polyback-website / 5d0cdca2e1e9b3c3c09f52c4f48b8cf10042ac86 / thumbs/status.php

1,147 bytes | parent directory

<?php
// Status placeholder thumbnails ("rendering", "pending", "unapproved"), drawn here: a soft
// grey card with a label, at the requested size.

$Status = $_GET["s"] ?? "rendering";
$Width = max(16, min(1024, (int) ($_GET["x"] ?? 420)));
$Height = max(16, min(1024, (int) ($_GET["y"] ?? 420)));
$Labels = ["rendering" => "Rendering...", "pending" => "Pending", "unapproved" => "Unavailable"];
$Label = $Labels[$Status] ?? "Unavailable";

header("Content-Type: image/png");
header("Cache-Control: public, max-age=300");

$img = imagecreatetruecolor($Width, $Height);
imagealphablending($img, false);
imagesavealpha($img, true);
imagefill($img, 0, 0, imagecolorallocatealpha($img, 0, 0, 0, 127));
imagealphablending($img, true);
$bg = imagecolorallocate($img, 228, 228, 228);
imagefilledrectangle($img, 0, 0, $Width - 1, $Height - 1, $bg);
$fg = imagecolorallocate($img, 140, 140, 140);
$font = $Width >= 200 ? 5 : ($Width >= 90 ? 3 : 1);
$tw = imagefontwidth($font) * strlen($Label);
$th = imagefontheight($font);
if ($tw < $Width) imagestring($img, $font, (int) (($Width - $tw) / 2), (int) (($Height - $th) / 2), $Label, $fg);
imagepng($img);