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:
14
CImage.php
14
CImage.php
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user