<?php
header ("Content-Type: image/jpeg");
$id = intval($_GET['id']);
 if(preg_match('#^[\d]{1,10}#',$id)){
	$files = glob("./foto/".$id."/*.jpeg");
	if(array_key_exists(0,$files))
	$p = explode("/",$files[0]);
	$name = explode(".",$p[3]);
	$infile = './foto/'.$id.'/'.$name[0].'.jpeg';
	$image = imageresize("",$infile,46,62,85);
 }

   function imageresize ($outfile,$infile,$neww,$newh,$quality) {
	$im=imagecreatefromjpeg($infile);
	$im1=imagecreatetruecolor($neww,$newh);
	imagecopyresampled ($im1,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
	imagejpeg($im1,$outfile,$quality);
	imagedestroy($im);
	imagedestroy($im1);
	return $outfile;
  }

?>