use GD; $first = "First Name"; $middle = "Middle Name"; $last = "Last Name"; $image = "/www/images/image.jpg"; $im = GD::Image->newFromJpeg($image); ($width, $height) = $im->getBounds(); $outim = new GD::Image($width, $height); $outim->copyResampled($im, 0, 0, 0, 0, $width, $height, $width, $height); # name $fgcolor = $outim->colorAllocate(0,0,0); $fontname = '/usr/share/fonts/dejavu/DejaVuSerif.ttf'; $ptsize = 20; $angle = 0; $x = 345; $y = 275; $string = ucfirst($first) . ($middle ne '' ? ' ' . ucfirst($middle) : '') . ' ' . ucfirst($last); @bounds = new GD::Image->stringFT($fgcolor,$fontname,$ptsize,$angle,$x,$y,$string); $left = ($outim->width() / 2) - (($bounds[2] - $bounds[0]) / 2) + 5; $top = ($outim->height() / 2) - ($bounds[7] - $bounds[1]) / 2; $outim->stringFT($fgcolor, $fontname,$ptsize,$angle,$left,$y,$string); # make sure we are writing to a binary stream binmode STDOUT; select(STDOUT); $| = 1; undef $/; $http_headers_out{'Content-Type'} = "image/png"; $escmode = 0; print OUT $outim->png();