note 87866 added to function.imagecopyresampled
| From: | MBorg_PL at osu1 dot php dot net | Date: | Sat, 27 Dec 2008 23:39:24 +0000 |
| Subject: | note 87866 added to function.imagecopyresampled | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148591@lists.php.net to get a copy of this message | ||
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();
?>
----
Server IP: 82.160.94.10
Probable Submitter: 83.6.146.122
----
Manual Page -- http://www.php.net/manual/en/function.imagecopyresampled.php
Edit -- https://master.php.net/note/edit/87866
Del: integrated -- https://master.php.net/note/delete/87866/integrated
Del: useless -- https://master.php.net/note/delete/87866/useless
Del: bad code -- https://master.php.net/note/delete/87866/bad+code
Del: spam -- https://master.php.net/note/delete/87866/spam
Del: non-english -- https://master.php.net/note/delete/87866/non-english
Del: in docs -- https://master.php.net/note/delete/87866/in+docs
Del: other reasons-- https://master.php.net/note/delete/87866
Reject -- https://master.php.net/note/reject/87866
Search -- https://master.php.net/manage/user-notes.php