Показать сообщение отдельно

  #10  
Старый 13.02.2010, 22:28
root_sashok
Познавший АНТИЧАТ
Регистрация: 04.08.2008
Сообщений: 1,359
С нами: 9351139

Репутация: 1593


По умолчанию

Как же вы надоели делать демотиваторы в фотошопе. Для этого есть скрипт.

PHP код:
<?php
  
//////// http://s.lurkmore.ru/images/a/ac/James_carriage.jpg
  // example of usage:
  // php dmotigen.php "James_carriage.jpg" "БАССЕЙН ЗАКРЫТ" "в нём дети и СПИД"
 
  // constants
  
$fontFolder "C:/Windows/Fonts/";
  
$fontExt ".ttf";
  
$headerFont "georgia";
  
$headerSize 32.5;
  
$textFont "arial";
  
$textSize 24.0;
 
  
$imageMargin 20;
  
$spacing 16;
  
$borderPad 16;
 
  
// php dmotigen.php pict head text
  
if( $_SERVER["argc"] != ){
    echo
      
"usage: dmotigen.php pict head text\n".
      
"\t pict - motivator image\n".
      
"\t head - motivator header\n".
      
"\t text - motivator text\n";
    exit;
  }
 
  
$srcFile $_SERVER["argv"][1];
  
$header iconv("CP1251""UTF-8"$_SERVER["argv"][2]);
  
$text iconv("CP1251""UTF-8"$_SERVER["argv"][3]);
 
  if( !
file_exists$srcFile ) ){
    echo 
"picture file not found\n";
    exit;
  }
 
  
$img imagecreatefromjpeg$srcFile );
  list(
$w$h) = getimagesize$srcFile );
 
  
$ha1 imagettfbbox($headerSize0$fontFolder.$headerFont.$fontExt$header );
  
$ha2 imagettfbbox($textSize0$fontFolder.$textFont.$fontExt$text );
 
  
$wt1 $ha1[2]-$ha1[0];
  
$ht1 $ha1[1]-$ha1[7];
  
$wt2 $ha2[2]-$ha2[0];
  
$ht2 $ha2[1]-$ha2[7];
 
  
$fw $w $imageMargin $borderPad 2;
  
$fh $h $imageMargin $borderPad $ht1 $ht2 $spacing 3;
  
$fon imagecreatetruecolor($fw$fh);
 
  
$white imagecolorallocate$fon255255255 );
  
$black imagecolorallocate$fon,   0,   0,   );
  
imagefill$fon00$black );
 
  
imagecopy$fon$img$imageMargin $borderPad 4$imageMargin $borderPad 400$w$h );
 
  
imagerectangle$fon$imageMargin $borderPad 3$imageMargin $borderPad 3,
           
$imageMargin $borderPad $w 2$imageMargin $borderPad $h 2$white );
  
imagerectangle$fon$imageMargin $borderPad 4$imageMargin $borderPad 4,
           
$imageMargin $borderPad $w 3$imageMargin $borderPad $h 3$white );
 
  
imagettftext$fon$headerSize0,
    (
$fw $wt1) / 2$imageMargin $borderPad*$h $ht1 $spacing,
    
$white$fontFolder.$headerFont.$fontExt$header );
 
  
imagettftext$fon$textSize0,
    (
$fw $wt2) / 2$imageMargin $borderPad*$h $ht1 $ht2 $spacing*2,
    
$white$fontFolder.$textFont.$fontExt$text );
 
  
imagejpeg$fon"dmotigen.jpg"98 );
  
imagecolordeallocate$fon$black );
  
imagecolordeallocate$fon$white );
  
imagedestroy$fon );
 
?>
 
Ответить с цитированием