Another tiny ammendment to zorroswordsman at gmail dot com's resize class AND matt at rees-jenkins dot co dot uk addition. The class may resize to different width and height not only same ones:
<?php
public function set_size($max_x = 100,$max_y = 100)
{
if($this->x_input > $max_x || $this->y_input > $max_y)
{
$a= $max_x / $max_y;
$b= $this->x_input / $this->y_input;
if ($a<$b)
{
$this->x_output = $max_x;
$this->y_output = ($max_x / $this->x_input) * $this->y_input;
}
else
{
$this->y_output = $max_y;
$this->x_output = ($max_y / $this->y_input) * $this->x_input;
}
$this->resize = TRUE;
}
else { $this->resize = FALSE; }
}
?>
And the use of the class is now:
<?php
$src = "myimage.jpg";
$img = new imaging;
$img->set_img($src);
$img->set_quality(80);
$img->set_size(250,150);
$img->save_img("small_250x150_" . $src);
$img->set_size(50,250);
$img->save_img("baby_50x250_" . $src);
$img->clear_cache();
?>