mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-08 00:56:31 +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.
|
// Use newWidth and newHeigh as max width/height, image should not be larger.
|
||||||
else {
|
else {
|
||||||
if($this->width > $this->height) {
|
$ratioWidth = $this->width/$this->newWidth;
|
||||||
$factor = (float)$this->newWidth / (float)$this->width;
|
$ratioHeight = $this->height/$this->newHeight;
|
||||||
$this->newHeight = $factor * $this->height;
|
$ratio = ($ratioWidth > $ratioHeight) ? $ratioWidth : $ratioHeight;
|
||||||
} else {
|
$this->newWidth = $this->width / $ratio;
|
||||||
$factor = (float)$this->newHeight / (float)$this->height;
|
$this->newHeight = $this->height / $ratio;
|
||||||
$this->newWidth = $factor * $this->width;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +188,8 @@ class CImage {
|
|||||||
$this->Output($this->pathToImage);
|
$this->Output($this->pathToImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//echo "{$this->newWidth}:{$this->newHeight}";
|
||||||
|
|
||||||
// Check cache before resizing.
|
// Check cache before resizing.
|
||||||
$this->newFileName = $this->CreateFilename();
|
$this->newFileName = $this->CreateFilename();
|
||||||
if(is_readable($this->newFileName)) {
|
if(is_readable($this->newFileName)) {
|
||||||
|
@@ -21,6 +21,11 @@ Mikael Roos (mos@dbwebb.se)
|
|||||||
Revision history
|
Revision history
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
v0.1.1 (2012-04-27)
|
||||||
|
|
||||||
|
* Corrected calculation where both width and height were set.
|
||||||
|
|
||||||
|
|
||||||
v0.1 (2012-04-25)
|
v0.1 (2012-04-25)
|
||||||
|
|
||||||
* Initial release after rewriting some older code I had lying around.
|
* Initial release after rewriting some older code I had lying around.
|
||||||
|
Reference in New Issue
Block a user