base64_encode($bytes)], JSON_THROW_ON_ERROR); $data = json_decode($payload, true, flags: JSON_THROW_ON_ERROR); $binary = base64_decode($data["picture"], true); if ($binary === false) { throw new UnexpectedValueException("Invalid base64"); } $loaded = imagecreatefromstring($binary); echo imagesx($loaded), "\n";