%
if( is_uploaded_file( $NewPhoto ) == 0 ) { return; }
$Ext= substr( $NewPhoto_name, strrpos( $NewPhoto_name, '.') + 1);
$Ext= strtolower( $Ext );
if( $Ext <> "jpg" and $Ext <> "jpeg" ) { return; }
include( 'Includes/CalcNewPhotoNo.php' );
if( $Err == 1 ) { return; }
$PhotoNo= $Counter;
$ExtraFilename= ".".time();
$Filename[$Counter]= $NewPhotoNo.$ExtraFilename;
$FinalPhoto= "PhotoStore/".$CatNo."/Photos/".$NewPhotoNo.$ExtraFilename.".jpg";
$Thumb= "PhotoStore/".$CatNo."/Thumbs/".$NewPhotoNo.$ExtraFilename.".jpg";
$Data= getimagesize( $NewPhoto );
$Width= $Data[0];
$Height= $Data[1];
$MaxSize= 90;
if( $Width > $Height ) { $Percentage= ( $MaxSize / $Width ); }
else { $Percentage= ( $MaxSize / $Height ); }
$ThumbWidth= round( $Width * $Percentage );
$ThumbHeight= round( $Height * $Percentage );
$NewWidth= $ThumbWidth * 8.4;
$NewHeight= $ThumbHeight * 8.4;
if( $Width < ( $MaxSize * 8.4 ) and $Height < ( $MaxSize * 8.4 ) ) {
$NewWidth= $Width; $NewHeight= $Height; }
//print $Width."
".$Height."
".$NewWidth."
".$NewHeight."
".$ThumbWidth."
".$ThumbHeight;
$TempPhoto= imageCreateTrueColor( $NewWidth,$NewHeight );
$Original= imageCreateFromJpeg( $NewPhoto );
imageCopyResampled( $TempPhoto,$Original,0,0,0,0,$NewWidth,$NewHeight,$Width,$Height );
imageJpeg( $TempPhoto, $FinalPhoto, 90 );
$TempThumb= imageCreateTrueColor( $ThumbWidth,$ThumbHeight );
$Original= imageCreateFromJpeg( $FinalPhoto );
imageCopyResampled( $TempThumb,$Original,0,0,0,0,$ThumbWidth,$ThumbHeight,$NewWidth,$NewHeight );
imageJpeg( $TempThumb, $Thumb, 95 );
$Caption= "PhotoStore/".$CatNo."/Captions/".$NewPhotoNo.$ExtraFilename.".txt";
Copy( "DefaultCaption.txt", $Caption );
$Title= "PhotoStore/".$CatNo."/Titles/".$NewPhotoNo.$ExtraFilename.".txt";
Copy( "DefaultTitle.txt", $Title );
include( 'Includes/SaveFilenames.php' );
%>