Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //content type
- header('Content-Type: image/png');
- //font
- $font = 'bangla2.ttf';
- $font_size = 20;
- $width = 640;
- $margin = 150;
- //$text = "আমার সোনার বাংলা";
- $text = " Avgvi †mvbvi evsjv Avwg ‡Zvgv‡K fv‡jvevwm";
- $text_a = explode(' ', $text);
- $text_new = '';
- foreach($text_a as $word){
- $box = imagettfbbox($font_size, 0, $font, $text_new.' '.$word);
- if($box[2] > $width - $margin*2){
- $text_new .= "\n".$word;
- } else {
- $text_new .= " ".$word;
- }
- }
- $text_new = trim($text_new);
- $box = imagettfbbox($font_size, 0, $font, $text_new);
- $height = $box[1] + $font_size + $margin * 2;
- $im = imagecreatefromjpeg('bg.jpg');
- $white = imagecolorallocate($im, 255, 255, 255);
- $black = imagecolorallocate($im, 0, 0, 0);
- imagettftext($im, $font_size, 0, $margin, $font_size+$margin, $black, $font, $text_new);
- imagepng($im);
- imagedestroy($im);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement