IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
//Instigate new Imagick objects.
$image= new Imagick(); //Image objects; for the working "canvas(es)"
$draw= new ImagickDraw(); //Drawing tools objects; container for shape and text layers
$color= new imagickPixel(); //Color tools objects; container for pixel colors
$color->setColor('skyblue');
$image->newImage(400, 200, $color); //Create the working image canvas, in pixels
$color->setColor('blue');
$draw->setStrokeColor($color); //Outline color for the next draw operation
$color->setColor('lightyellow');
$draw->setFillColor($color); //Fill color for the next draw operation
$draw->rectangle(0, 0, 120, 100); //Draw a rectangle in the upper left, in pixels
$color->setColor("darkred"); //font color
$draw->setFillColor($color);
$draw->setFont("Bookman-DemiItalic"); //Set the font
$draw->setFontSize(60); //Font pixels size
$draw->annotation(20, 160, 'Test'); //Add annotation layer. Note that the stroke color is the last one assigned
$image->drawImage($draw); //Add all drawing layers to image canvas
$image->SetImageFormat('jpeg');
$image->writeImage('Imagick_ex.jpg'); //Write jpg file in current directory. Directory must have proper permissions
echo "<img alt=\"image missing\" src=\"./Imagick_ex.jpg\">\n\n";
I don't the browsers support embedding the image contents into the HTML. Effectively you would be doing the same as copy pasting the image contents into your HTML.