From 7849f69801a0e8c868d585e18f88a1a46a9b362d Mon Sep 17 00:00:00 2001 From: Mikael Roos Date: Tue, 15 Oct 2013 01:01:15 +0200 Subject: [PATCH] support jpeg file extension --- CImage.php | 21 +++++++++++++++++++-- README.md | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CImage.php b/CImage.php index 8693f9a..69f42e9 100644 --- a/CImage.php +++ b/CImage.php @@ -109,11 +109,11 @@ class CImage { foreach($this->log as $val) { if(is_array($val)) { foreach($val as $val1) { - $log .= $val1 . '
'; + $log .= htmlentities($val1) . '
'; } } else { - $log .= $val . '
'; + $log .= htmlentities($val) . '
'; } } @@ -561,6 +561,13 @@ EOD; // Use newWidth and newHeigh as defined width/height, image should fit the area. if($this->cropToFit) { + /* + if($cropToFit && $newWidth && $newHeight) { + $targetRatio = $newWidth / $newHeight; + $cropWidth = $targetRatio > $aspectRatio ? $width : round($height * $targetRatio); + $cropHeight = $targetRatio > $aspectRatio ? round($width / $targetRatio) : $height; + } + */ $ratioWidth = $width / $this->newWidth; $ratioHeight = $height / $this->newHeight; $ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight; @@ -924,6 +931,15 @@ EOD; // Resize by crop to fit if($this->cropToFit) { + /* + $cropX = round(($width - $cropWidth) / 2); + $cropY = round(($height - $cropHeight) / 2); + $imageResized = createImageKeepTransparency($newWidth, $newHeight); + imagecopyresampled($imageResized, $image, 0, 0, $cropX, $cropY, $newWidth, $newHeight, $cropWidth, $cropHeight); + $image = $imageResized; + $width = $newWidth; + $height = $newHeight; + */ $this->Log("Crop to fit"); $cropX = round(($this->cropWidth/2) - ($this->newWidth/2)); $cropY = round(($this->cropHeight/2) - ($this->newHeight/2)); @@ -996,6 +1012,7 @@ EOD; */ protected function SaveToCache() { switch($this->extension) { + case 'jpeg': case 'jpg': if($this->saveFolder) { $this->Log("Saving image as JPEG to cache using quality = {$this->quality}."); diff --git a/README.md b/README.md index 82e2768..73eadac 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,8 @@ v0.4.x (latest) * Changed => to == on Modified-Since. * Always send Last-Modified-Header. +* Added `htmlentities()` to verbose output. +* Fixed support for jpeg, not only jpg. v0.4 (2013-10-08)