All pastes #419152 Raw Edit

frankr

public text v1 · immutable
·published 2007-04-01 02:41 UTC
rendered paste body
<?php 

  Header("Content-type: image/jpeg");
  
  include("inc/conf.inc"); 
  $fi="$dir/PICT$id.JPG"; 
  $bottom=stripslashes($bottom); $top=stripslashes($top);
  if ($f=="") $f="i"; 

  function mkd($imi) { imagejpeg($imi); imagedestroy($imi); }

  function cal($i,$n) { return imagecolorallocate($i, $n,$n,$n); }
    
  function ixc($p,$im,$tx) { global $bottextsize, $cfs; $fz=$cfs; if ($p==3) $fz=$bottextsize; 
  $s=imagettfbbox($fz,0,"arial.ttf",$tx); if ($p!=3) return (imagesx($im)/2)-($s[2]/2); else 
  return (imagesx($im)-$s[2]-5); }
  
  function txw($im) { global $font,$top,$bottom,$website,$bottextsize,$cfs,$email; if($top!="") 
  imagettftext($im, $cfs, 0, ixc(1,$im,$top), 40, cal($im,255), $font, $top);
  if($bottom!="") imagettftext($im, $cfs, 0, ixc(2,$im,$bottom), imagesy($im)-40, cal($im,255), $font, $bottom);
  imagettftext($im, $bottextsize, 0, ixc(3,$im,$email), imagesy($im)-5, cal($im,255), $font, $email); 
  imagettftext($im, $bottextsize, 0, 1, imagesy($im)-5, cal($im,255), $font, $website); }
  
  function aspx($im) { $aspect = imagesx($im) / imagesy($im); return 160*$aspect; }
  
  if(!file_exists($fi)) { $im = imagecreate(500,17); $cb=imagecolorallocate($im, 0,0,0); 
  $cw=imagecolorallocate($im, 255,255,255); imagefill($im, 0, 0, $cw); imagettftext($im, 12, 0, 1, 12, $cb, 
  "arial.ttf", "The image you requested with an ID # of $id could not be found."); mkd($im); } 
  
  elseif ($f=="i") { 
  $im=imagecreatefromjpeg($fi); if ($caption=="no") mkd($im); else { txw($im); mkd($im);} } 
  
  elseif ($f=="t") { 
  if(!File_exists($dir . "/PICT" . $id . "t.JPG")) { $im = imagecreatefromjpeg($fi);
  $thumb = imagecreatetruecolor(axpx($im), 160); imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight,
  imagesx($im), imagesy($im)); imagedestroy($im); $nfn=$dir . "/PICT" . $id . "t.JPG"; imagejpeg($thumb,$nfn,70); 
  mkd($thumb); } else { $im=imagecreatefromjpeg($dir . "/PICT" . $id . "t.JPG"); mkd($im); }

?>