Wie kann man ein Bild dynamisch erzeugen in PHP?
To dynamically generate an image in PHP, you can use the GD library which provides functions to create and manipulate images. You can create a new image, draw shapes, add text, and save the image in various formats such as PNG, JPEG, or GIF.
<?php
// Create a blank image with a width and height
$image = imagecreatetruecolor(200, 200);
// Set the background color
$bgColor = imagecolorallocate($image, 255, 255, 255);
// Set the text color
$textColor = imagecolorallocate($image, 0, 0, 0);
// Add text to the image
imagestring($image, 5, 50, 50, "Dynamic Image", $textColor);
// Set the content type header
header('Content-type: image/png');
// Output the image
imagepng($image);
// Free up memory
imagedestroy($image);
?>