Yeah that's exactly what it's for. As long as you have GD and PHP. Just copy/paste the below code into a file called "image.php" (or whatever you want) and then call it out on any page by using a standard HTML image command, such as:
<IMG SRC=/PATH/TO/image.php?imgfile=PATH/TO/your_image.jpg>
or
<IMG SRC=/PATH/TO/image.php?imgfile=PATH/TO/your_image.jpg&width=100>
or
<IMG SRC=/PATH/TO/image.php?imgfile=PATH/TO/your_image.jpg&height=207>
or
<IMG SRC=/PATH/TO/image.php?imgfile=PATH/TO/your_image.jpg&width=151&height=800>
or
<IMG SRC=/PATH/TO/image.php?imgfile=PATH/TO/your_image.jpg&thumbnailmax=245>
Here's the code...
<?php
$oldimg = ImageCreateFromjpeg("$imgfile");
$dw = ImageSX($oldimg);
$dh = ImageSY($oldimg);
if ($thumbnailmax)
{
if ($dw > $dh)
{
$aspect = $dh / $dw;
$tmp = $thumbnailmax * $aspect;
$neww = $thumbnailmax;
$newh = round($tmp,0);
}
else
{
$aspect = $dw / $dh;
$tmp = $thumbnailmax * $aspect;
$newh = $thumbnailmax;
$neww = round($tmp,0);
}
}
elseif (($width) OR ($height))
{
if ($width)
{
$aspect = $dh / $dw;
$tmp = $width * $aspect;
$neww = $width;
$newh = round($tmp,0);
}
if ($height)
{
$aspect = $dw / $dh;
$tmp = $height * $aspect;
$newh = $height;
$neww = round($tmp,0);
}
if (($width) && ($height))
{
$neww = $width;
$newh = $height;
}
}
else
{
$aspect = $dh / $dw;
// CHANGE $width TO PREDETERMINED WIDTH SIZE OR LEAVE AS $dw TO DISPLAY TRUE SIZE WITHOUT URL VARIABLE
$width = $dw;
$tmp = $width * $aspect;
$neww = $width;
$newh = round($tmp,0);
}
$newimg = imagecreatetruecolor($neww,$newh);
ImageCopyResized($newimg,$oldimg,0,0,0,0,$neww,$newh,$dw,$dh);
header("Content-Type: image/jpeg");
imagejpeg($newimg);
?>