Может подобное уже выкладывали, в этом варианте исправил масштабирование. Всё работает корректно.
functions_upload.php
найти функцию
Код: Выделить всё
function move_file(
Код: Выделить всё
phpbb_chmod($this->destination_file, $chmod);
Код: Выделить всё
if ( $this->is_image() )
{
$this->resize_images();
}
Код: Выделить всё
return true;
}
Код: Выделить всё
/**
* Resize images with the true diemensions
* version 0.31
*/
function resize_images()
{
if ( $this->is_image() )
{
$limit_width = 1024;
$limit_height = 768;
$quality = 90;
$size = getimagesize($this->destination_file);
$width = $size[0];
$height = $size[1];
if($height > $limit_height OR $width > $limit_width)
{
$int_factor = min(($limit_width / $width), ($limit_height / $height));
// pano-test add
// if (max($width, $height) / min($width, $height) > 2) $int_factor = $int_factor * 1.5;
// end
$width = round($width * $int_factor);
$height = round($height * $int_factor);
$destination = imagecreatetruecolor($width, $height);
if ( $this->extension == "jpg" || $this->extension == "jpeg" )
{
@ini_set('gd.jpeg_ignore_warning', 1);
$source = imagecreatefromjpeg($this->destination_file);
}
elseif ( $this->extension == "png" )
{
@imagealphablending($destination, false);
@imagesavealpha($destination, true);
$source = imagecreatefrompng($this->destination_file);
}
elseif ( $this->extension == "gif" )
{
$source = imagecreatefromgif($this->destination_file);
$trnprt_indx = imagecolortransparent($source);
if ($trnprt_indx >= 0) //transparent
{
$trnprt_color = imagecolorsforindex($source, $trnprt_indx);
$trnprt_indx = imagecolorallocate($destination, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
imagefill($destination, 0, 0, $trnprt_indx);
imagecolortransparent($destination, $trnprt_indx);
}
}
imagecopyresampled($destination, $source, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
if ( $this->extension == "jpg" || $this->extension == "jpeg" ) imagejpeg($destination, $this->destination_file, $quality);
elseif ( $this->extension == "png" ) imagepng($destination, $this->destination_file);
elseif ( $this->extension == "gif" ) imagegif($destination, $this->destination_file);
imagedestroy($destination);
}
}
}
Оформлено в виде мода в стандарте MODX + управление через ACP --> [Beta]Upload image resizer