rendered paste body function resizeImage($filename, $writeto, $max_width, $max_height)
{
if ($this->method == 'gd' OR !isset($this->method))
{
list($orig_width, $orig_height) = getimagesize($filename);
$width = $orig_width;
$height = $orig_height;
if ($height > $max_height)
{
$width = ($max_height / $height) * $width;
$height = $max_height;
}
if ($width > $max_width)
{
$height = ($max_width / $width) * $height;
$width = $max_width;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0,
$width, $height, $orig_width, $orig_height);
$image_p = imagejpeg($image_p, $writeto, 100);
}
elseif ($this->method == 'imagemagick')
{
list($orig_width, $orig_height) = getimagesize($filename);
$width = $orig_width;
$height = $orig_height;
if ($height > $max_height)
{
$width = ($max_height / $height) * $width;
$height = $max_height;
}
if ($width > $max_width)
{
$height = ($max_width / $width) * $height;
$width = $max_width;
}
shell_exec($this->imagemagickpath . ' ' . $filename . " -geometry " . $width . "x" . $height." -quality 90 " . $writeto);
}
}