diff --git a/CImage.php b/CImage.php index 797bb27..7fba269 100644 --- a/CImage.php +++ b/CImage.php @@ -600,6 +600,26 @@ class CImage + /** + * Normalize the file extension. + * + * @param string $extension of image file or skip to use internal. + * + * @return string $extension as a normalized file extension. + */ + private function normalizeFileExtension($extension = null) + { + $extension = strtolower($extension ? $extension : $this->extension); + + if ($extension == 'jpeg') { + $extension = 'jpg'; + } + + return $extension; + } + + + /** * Download a remote image and return path to its local copy. * @@ -1279,6 +1299,9 @@ class CImage $rotateBefore = $this->rotateBefore ? "_rb{$this->rotateBefore}" : null; $rotateAfter = $this->rotateAfter ? "_ra{$this->rotateAfter}" : null; + $saveAs = $this->normalizeFileExtension(); + $saveAs = $saveAs ? "_$saveAs" : null; + $width = $this->newWidth; $height = $this->newHeight; @@ -1336,7 +1359,7 @@ class CImage . $quality . $filters . $sharpen . $emboss . $blur . $palette . $optimize . $compress . $scale . $rotateBefore . $rotateAfter . $autoRotate . $bgColor - . $convolve; + . $convolve . $saveAs; return $this->setTarget($file, $base); } diff --git a/REVISION.md b/REVISION.md index d356939..2bd6d14 100644 --- a/REVISION.md +++ b/REVISION.md @@ -8,7 +8,8 @@ Revision history v0.7.6* (2015-10-20) ------------------------------------- -* Add extra fileds to json-response, #114. +* Adding save-as as part of the generated cache filename, #121. +* Add extra fields to json-response, #114. * Add header for Content-Length, #111. * Add check for postprocessing tools in path in `webroot/check_system.php`, #104.