PHP Classes

Bug resizing?

Recommend this page to a friend!

      phpThumbnailer  >  All threads  >  Bug resizing?  >  (Un) Subscribe thread alerts  
Subject:Bug resizing?
Summary:When resizing an image smaller than the maximal width & height
Messages:1
Author:Kacior
Date:2007-08-12 22:39:18
 

  1. Bug resizing?   Reply   Report abuse  
Picture of Kacior Kacior - 2007-08-12 22:39:19
When resizing an image smaller than the maximal width & height I get an error in the resizing. Because I use the script for images uploaded to my website there is a need also for not resizing if the image is smaller.
I fixed it by sending the old width and height in the calc_image_size-function if no changes were made:

function calc_image_size($width, $height) {
$new_size = array($width, $height); // Aktuell storlek
// this-> Maximal ny
$status = FALSE;
if ($this->max_width > 0 && $width > $this->max_width) {
$status = TRUE;
$new_size = $this->calc_width($width, $height);

if ($this->max_height > 0 && $new_size[1] > $this->max_height) {
$new_size = $this->calc_height($new_size[0], $new_size[1]);
}

return $this->return_value($new_size);
}

if ($this->max_height > 0 && $height > $this->max_height) {
$status = TRUE;
$new_size = $this->calc_height($width, $height);
return $this->return_value($new_size);
}

if ($this->percent > 0) {
$status = TRUE;
$new_size = $this->calc_percent($width, $height);
return $this->return_value($new_size);
}

if(!$status) return $this->return_value($new_size);
}