PHP Solution:
-----------------------------------------------------
FUNCTION
-----------------------------------------------------
function createThumbnail($img_file, $max_width, $max_height, $img_quality, $img_path='images', $class='', $alt_tag='') {
$nameparts = pathinfo($img_file);
$file_extension = $nameparts['extension'];
$thumb_script = "create_thumbs.php";
$z = "<img src=\"" . $thumb_script . "?photo_file=" . $img_path . "/" . $img_file . "&maxW=" . $max_width . "&maxH=" . $max_height . "&quality=" . $img_quality . "\" alt=\"" . $alt_tag . "\" class=\"" . $class . "\" />";
echo $z;
}
-----------------------------------------------------
'create_thumbs.php' PAGE
-----------------------------------------------------
<?php
!isset($_GET['maxW']) ? $_GET['maxW']=400 : NULL;
!isset($_GET['maxH']) ? $_GET['maxH']=400 : NULL;
!isset($_GET['quality']) ? $_GET['quality']=100 : NULL;
$ratio=1;
$sourceHandle=imagecreatefromjpeg($_GET['photo_file']);
$sourceW=imagesx($sourceHandle);
$sourceH=imagesy($sourceHandle);
if ($sourceW>$sourceH) { $sourceW>$_GET['maxW'] ? $ratio=$_GET['maxW']/$sourceW : NULL; } elseif ($sourceW<$sourceH) { $sourceH>$_GET['maxH'] ? $ratio=$_GET['maxH']/$sourceH : NULL; } else { $ratio=min($_GET['maxH'],$_GET['maxW'])/$sourceH; }
$resizedW=$sourceW*$ratio;
$resizedH=$sourceH*$ratio;
$resizedHandle=imagecreatetruecolor($resizedW,$resizedH);
imagecopyresampled($resizedHandle,$sourceHandle,0,0,0,0,$resizedW,$resizedH,$sourceW,$sourceH);
//$resizedHandle=imagecreate($resizedW,$resizedH);
//imagecopyresized($resizedHandle,$sourceHandle,0,0,0,0,$resizedW,$resizedH,$sourceW,$sourceH);
header('Content-type: image/jpeg');
imagejpeg($resizedHandle,'',$_GET['quality']);
imagedestroy($sourceHandle);
imagedestroy($resizedHandle);
?>
-----------------------------------------------------
CALL TO IMAGE WITHIN HTML
-----------------------------------------------------
<?php createThumbnail($FILENAME,130,130,90,'FILE_PATH'); ?>