All pastes #757882 Raw Edit

Meins

public text v1 · immutable
·published 2007-11-01 18:35 UTC
rendered paste body
<?php 
#   Copyright by Manuel Staechele
#   Support www.ilch.de


defined ('main') or die ( 'no direct access' );

function create_thumb ( $imgpath, $thumbpath, $neueBreite ) {
$neueHoehe = $neueBreite;
	$size=getimagesize($imgpath);
	
  $hoehe=$size[0];
  $breite=$size[1];
  $neueBreite=intval($breite*$neueHoehe/$hoehe);
	
  if (function_exists('gd_info')) {
    $tmp = gd_info();
    $imgsup = ($tmp['GIF Create Support'] ? 1 : 2);
    unset($tmp);
  }	else $imgsup = 2;
	
  if ($size[2] < $imgsup OR $size[2] > 3) { return (FALSE); }
   
  if ($size[2] == 1) {
    $altesBild = imagecreatefromgif($imgpath);
  } elseif ($size[2] == 2) {
    $altesBild = imagecreatefromjpeg($imgpath);
  } elseif ( $size[2] == 3 ) {
    $altesBild = imagecreatefrompng($imgpath);
  }
  if ( function_exists ( 'imagecreatetruecolor' ) AND $size[2] != 1 ) {
    $neuesBild = imagecreatetruecolor($neueBreite,$neueHoehe);
    imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite,$neueHoehe, $breite, $hoehe);
  } else {
    $neuesBild=imageCreate($neueBreite,$neueHoehe);
    imageCopyResized($neuesBild,$altesBild,0,0,0,0,$neueBreite,$neueHoehe,$breite,$hoehe);
  }
  if ($size[2] == 1) {
    ImageGIF($neuesBild,$thumbpath);
  }	elseif ($size[2] == 2) {
    ImageJPEG($neuesBild,$thumbpath);
  } elseif ( $size[2] == 3 ) {
    ImagePNG($neuesBild,$thumbpath); 
  }
  return (TRUE);
}

?>