1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-06 16:16:39 +02:00

Corrected calculation where both width and height were set.

This commit is contained in:
Mikael Roos
2012-04-27 08:35:16 +02:00
parent 980b4cce3c
commit 5377b1441a
2 changed files with 12 additions and 7 deletions

View File

@@ -147,13 +147,11 @@ class CImage {
// Use newWidth and newHeigh as max width/height, image should not be larger.
else {
if($this->width > $this->height) {
$factor = (float)$this->newWidth / (float)$this->width;
$this->newHeight = $factor * $this->height;
} else {
$factor = (float)$this->newHeight / (float)$this->height;
$this->newWidth = $factor * $this->width;
}
$ratioWidth = $this->width/$this->newWidth;
$ratioHeight = $this->height/$this->newHeight;
$ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;
$this->newWidth = $this->width / $ratio;
$this->newHeight = $this->height / $ratio;
}
}
@@ -190,6 +188,8 @@ class CImage {
$this->Output($this->pathToImage);
}
//echo "{$this->newWidth}:{$this->newHeight}";
// Check cache before resizing.
$this->newFileName = $this->CreateFilename();
if(is_readable($this->newFileName)) {

View File

@@ -21,6 +21,11 @@ Mikael Roos (mos@dbwebb.se)
Revision history
----------------
v0.1.1 (2012-04-27)
* Corrected calculation where both width and height were set.
v0.1 (2012-04-25)
* Initial release after rewriting some older code I had lying around.