Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function __vertical( $name, $text ) {
  2.     $DRoot = $_SERVER['DOCUMENT_ROOT'] ;
  3.     // Подключаем шрифт
  4.     $font = $DRoot."/fonts/arial.ttf" ;
  5.    
  6.     $im = ImageCreate( 190, 20 ) ;
  7.     $background_color = ImageColorAllocate( $im, 255, 255, 255 ) ;
  8.     $text_color = ImageColorAllocate($im, 0, 0, 0 ) ;
  9.    
  10.     // Рисуем текст на картинке
  11.     ImageTTFText( $im , 12 , 0, 2, 15, $text_color, $font, $text ) ;
  12.     ImagePNG( $im, $DRoot."/temp/cache.png") ;
  13.    
  14.     // Переворачиваем картинку на 90 градусов
  15.     $im2 = imagerotate( $im, 90, 0 ) ;
  16.    
  17.     // А может картинку уже существует? Проверяем.
  18.     if( !file_exists( $DRoot.'/images/vert_'.$name.'.png' ) ) {
  19.         ImagePNG($im2, $DRoot.'/images/vert_'.$name.'.png' ) ;
  20.         ImageDestroy( $im2 ) ;
  21.     }
  22.     ImageDestroy( $im ) ;
  23.    
  24.     // Удаляем временное изображение
  25.     if( file_exists( DRoot.'/temp/cache.png' ) ) {
  26.         unlink( DRoot.'/temp/cache.png' ) ;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement