mirror of
https://github.com/mosbth/cimage.git
synced 2025-07-23 17:51:34 +02:00
support jpeg file extension
This commit is contained in:
21
CImage.php
21
CImage.php
@@ -109,11 +109,11 @@ class CImage {
|
|||||||
foreach($this->log as $val) {
|
foreach($this->log as $val) {
|
||||||
if(is_array($val)) {
|
if(is_array($val)) {
|
||||||
foreach($val as $val1) {
|
foreach($val as $val1) {
|
||||||
$log .= $val1 . '<br/>';
|
$log .= htmlentities($val1) . '<br/>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$log .= $val . '<br/>';
|
$log .= htmlentities($val) . '<br/>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,6 +561,13 @@ EOD;
|
|||||||
|
|
||||||
// Use newWidth and newHeigh as defined width/height, image should fit the area.
|
// Use newWidth and newHeigh as defined width/height, image should fit the area.
|
||||||
if($this->cropToFit) {
|
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;
|
$ratioWidth = $width / $this->newWidth;
|
||||||
$ratioHeight = $height / $this->newHeight;
|
$ratioHeight = $height / $this->newHeight;
|
||||||
$ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;
|
$ratio = ($ratioWidth < $ratioHeight) ? $ratioWidth : $ratioHeight;
|
||||||
@@ -924,6 +931,15 @@ EOD;
|
|||||||
|
|
||||||
// Resize by crop to fit
|
// Resize by crop to fit
|
||||||
if($this->cropToFit) {
|
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");
|
$this->Log("Crop to fit");
|
||||||
$cropX = round(($this->cropWidth/2) - ($this->newWidth/2));
|
$cropX = round(($this->cropWidth/2) - ($this->newWidth/2));
|
||||||
$cropY = round(($this->cropHeight/2) - ($this->newHeight/2));
|
$cropY = round(($this->cropHeight/2) - ($this->newHeight/2));
|
||||||
@@ -996,6 +1012,7 @@ EOD;
|
|||||||
*/
|
*/
|
||||||
protected function SaveToCache() {
|
protected function SaveToCache() {
|
||||||
switch($this->extension) {
|
switch($this->extension) {
|
||||||
|
case 'jpeg':
|
||||||
case 'jpg':
|
case 'jpg':
|
||||||
if($this->saveFolder) {
|
if($this->saveFolder) {
|
||||||
$this->Log("Saving image as JPEG to cache using quality = {$this->quality}.");
|
$this->Log("Saving image as JPEG to cache using quality = {$this->quality}.");
|
||||||
|
@@ -87,6 +87,8 @@ v0.4.x (latest)
|
|||||||
|
|
||||||
* Changed => to == on Modified-Since.
|
* Changed => to == on Modified-Since.
|
||||||
* Always send Last-Modified-Header.
|
* Always send Last-Modified-Header.
|
||||||
|
* Added `htmlentities()` to verbose output.
|
||||||
|
* Fixed support for jpeg, not only jpg.
|
||||||
|
|
||||||
|
|
||||||
v0.4 (2013-10-08)
|
v0.4 (2013-10-08)
|
||||||
|
Reference in New Issue
Block a user