diff --git a/textgen.php b/textgen.php new file mode 100644 index 0000000..c09bd58 --- /dev/null +++ b/textgen.php @@ -0,0 +1,93 @@ +setFont( $font ); +$draw->setFontSize( $fontsize ); +$draw->setFillColor( $textcolor ); +$draw->setTextAlignment( Imagick::ALIGN_CENTER ); + +$imagick = new Imagick(); +$imagick->newImage( $workwidth, $workheight, $backgroundcolor ); +$imagick->setImageFormat( 'png' ); + +$metrics = $imagick->queryFontMetrics( $draw, $string ); +$textwidth = $metrics['textWidth']; +$textheight = $metrics['textHeight']; + +$xcord = ( $workwidth / 2 ); +$ycord = ( $workheight / 2 ) + ( $textheight / 4 ); + +$imagick->annotateImage( $draw, $xcord, $ycord, 0, $string ); + +$imagick->resizeImage( $finalwidth, $finalheight, Imagick::FILTER_LANCZOS, 1 ); + +header( 'Content-type: image/png' ); +if ( $download ) { + header( "Content-Disposition: attachment; filename=\"${string}.png\"" ); +} + +echo $imagick; +$imagick->clear(); +$imagick->destroy();