Voting

: max(three, nine)?
(Example: nine)

The Note You're Voting On

MBorg_PL
16 years ago
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
// Set maximum image size (pixels)
public function set_size($max_x = 100,$max_y = 100)
{

// Resize
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;

}
// Ready

$this->resize = TRUE;

}

// Don't resize
else { $this->resize = FALSE; }

}
?>

And the use of the class is now:

<?php

##### DEMO #####

// Image
$src = "myimage.jpg";

// Begin
$img = new imaging;
$img->set_img($src);
$img->set_quality(80);

// Small thumbnail
$img->set_size(250,150);
$img->save_img("small_250x150_" . $src);

// Baby thumbnail
$img->set_size(50,250);
$img->save_img("baby_50x250_" . $src);

// Finalize
$img->clear_cache();

?>

<< Back to user notes page

To Top