<?php
/*
 * alvsky gallery v1.11
 * ===============                                                          
 *                                                                      
 * Copyright (c) 2005 by Alvsky <alvsky@gmail.com>                  
 *                                    
 *
 * This program is free stware; you can redistribute it and/or
 * modify it as ever you wish.
 *
 *The script is comprised of two script's functionality (mmgallery by madmaz <madmaz@netfriends.it> 
 *and 35mm Slide Gallery 6.0 by www.andymack.com/freescripts/)
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY.
 * 
 */
 
 $croptofit = true ; //TRUE will crop the thumbnail to fit the aspect ratio of the slide mount if they aren't the same. False won't crop the thumbnail but it will be distorted if both aspect ratios are not the same.
$image = $_GET['image'] ; 
$size = getimagesize ($image);

$long=105;
$newwidthv = 105;
$newheightv = 70;


// $height = $_GET['height'];
// $width = $_GET['width'];

$height = $size[1];
$width = $size[0];

if ($width > $height)
{
$newwidth = $long;
$newheight = $long * 2/3;
}
else
{
$newheight = $long;
$newwidth = $long * 2/3;
}

$correctheight = round($width/2*3);
$correctwidth = round($height/3*2);
$correctheightb = round($width/3*2);
$correctwidthb = round($height/2*3);
$ratio = ($height/$width);
$src = imagecreatefromjpeg("$image");
$im = imagecreatetruecolor($newwidth,$newheight);  

if ($croptofit)
	{
	if ($height > $width)
		{ 
		if ($ratio > 1.5)
			{
			$newy = round(($height-$correctheight)/2);
			imagecopyresampled($im,$src,0,0,0,$newy,$newwidth,$newheight,$width,$correctheight); 
			}
		else
			{
			$newx = round(($width-$correctwidth)/2);
			imagecopyresampled($im,$src,0,0,$newx,0,$newwidth,$newheight,$correctwidth,$height); 
			}
		}
		else
		if ($ratio < 0.67)
			{
			$newx = round(($width-$correctwidthb)/2);
			imagecopyresampled($im,$src,0,0,$newx,0,$newwidth,$newheight,$correctwidthb,$height); 
			}
		else
			{
			$newy = round(($height-$correctheightb)/2);
			imagecopyresampled($im,$src,0,0,0,$newy,$newwidth,$newheight,$width,$correctheightb); 
			}
		}
	else
	{
	imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height); 
	}

imagejpeg($im, '',85); 
//imagegif($im); 
imagedestroy($im); 





?>