Hey Tobi,
I wanted to do something similar a while ago, but didn’t need it in the end. So my solution is not finished, but proberly it can give you a starting point. It’s a Field with hook, that creates and saves the image in the contentfolder. Here is my plugin code:
?php
kirby()->hook('panel.page.update', function($page) {
$name = $page->content()->get('name');
if($name != ''){
$slug = strtolower($name);
$slug = preg_replace("/[\s_]/", "-", $slug);
$uml = array("ä", "ö", "ü", "ß", "´");
$nouml = array("ae", "oe", "ue", "ss", "");
$slug = str_replace($uml, $nouml, $slug);
$filename = $page->uid() . '_' . $slug;
$font = __DIR__ . '/arial.ttf'; // Your Fontfile
$fontsize = 25;
$im = @imagecreatetruecolor(strlen($name) * $fontsize / 1.5, $fontsize);
imagesavealpha($im, true);
imagealphablending($im, false);
$white = imagecolorallocatealpha($im, 255, 255, 255, 127);
imagefill($im, 0, 0, $white);
$color = imagecolorallocate($im, 204, 55, 51);
$outputImage = $page->root() . '/' . $filename . '.png';
imagettftext($im, $fontsize, 0, 0, $fontsize - 3, $color, $font, $name);
imagepng($im, $outputImage, 0);
imagedestroy($im);
}
});
Like @jimbobrjames said, most of the code is from stackoverflow but it should do the trick.
cheers
tom