If u set max width bigger then max height in the settings and tryed to resize an image witch width is smaller then height, after resize it height will be equal to max width, but bigger then max height.
This is because 4images uses max width as max dimentions when resizing images.
To correct this and resize images acording your max widht AND max height, do this:
Step 1
Open includes/image_utils.php
Find:
function get_width_height($dimension, $width, $height, $resize_type = 1) {
if ($resize_type == 2) {
$new_width = $dimension;
$new_height = floor(($dimension/$width) * $height);
}
elseif ($resize_type == 3) {
$new_width = floor(($dimension/$height) * $width);
$new_height = $dimension;
}
else {
$ratio = $width / $height;
if ($ratio > 1) {
$new_width = $dimension;
$new_height = floor(($dimension/$width) * $height);
}
else {
$new_width = floor(($dimension/$height) * $width);
$new_height = $dimension;
}
}
return array("width" => $new_width, "height" => $new_height);
}
Replace it with:
function get_width_height($dimension, $width, $height, $resize_type = 1, $max_height = false) {
$max_width = $dimension;
$max_height = ($max_height === false) ? $max_width : $max_height;
if ($resize_type == 2)
{
$new_width = $max_width;
$new_height = floor(($max_width/$width) * $height);
}
elseif ($resize_type == 3)
{
$new_width = floor(($max_height/$height) * $width);
$new_height = $max_height;
}
else
{
$new_width = $width;
$new_height = $height;
if ($width > $max_width || $height > $max_height)
{
$scale = min($max_width/$width, $max_height/$height);
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
}
}
return array("width" => $new_width, "height" => $new_height);
}
Step 1.2
Find:
function resize_image($file, $quality, $dimension, $resize_type = 1) {
Replace it with:
function resize_image($file, $quality, $dimension, $resize_type = 1, $height = false) {
Step 1.3
Find:
$width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
Replace it with:
$width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type, $height);
Step 2
Open admin/resizer.php
Find:
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : 200;
$resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : 1;
Replace it with:
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $config['max_image_width'];
$height = (isset($HTTP_POST_VARS['height'])) ? intval($HTTP_POST_VARS['height']) : $config['max_image_height'];
$resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : $config['auto_thumbnail_resize_type'];
Step 2.2
Find:
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : 200;
$resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : 1;
Replace it with:
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $config['max_image_width'];
$height = (isset($HTTP_POST_VARS['height'])) ? intval($HTTP_POST_VARS['height']) : $config['max_image_height'];
$resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : $config['auto_thumbnail_resize_type'];
Step 2.3
Find:
show_input_row($lang['resize_dimension_desc'], "dimension", $dimension);
Replace it with:
show_input_row($lang['max_imagewidth'], "dimension", $dimension);
show_input_row($lang['max_imageheight'], "height", $height);
Step 2.4
Find:
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : 200;
Replace it with:
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $config['max_image_height'];
$height = (isset($HTTP_POST_VARS['height'])) ? intval($HTTP_POST_VARS['height']) : $config['max_image_height'];
Step 2.5
Find:
if ($resize_type == 1 && ($image_info[0] > $dimension || $image_info[1] > $dimension)) {
Replace it with:
if ($resize_type == 1 && ($image_info[0] > $dimension || $image_info[1] > $height)) {
Step 2.6
Find:
elseif ($resize_type == 3 && $image_info[1] > $dimension) {
Replace it with:
elseif ($resize_type == 3 && $image_info[1] > $height) {
Step 2.7
Find:
$width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
Replace it with:
$width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type, $height);
Step 2.8
Find:
show_hidden_input("dimension", $dimension);
Add above:
show_hidden_input("height", $height);