1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-03 22:57:43 +02:00

prepare to tag v0.7.12

This commit is contained in:
Mikael Roos
2016-06-01 09:34:30 +02:00
parent 9e9c44c935
commit 5edbfc9b54
5 changed files with 73 additions and 21 deletions

View File

@@ -8,7 +8,7 @@
* *
*/ */
$version = "v0.7.11 (2016-04-18)"; $version = "v0.7.12 (2016-05-31)";
// For CRemoteImage // For CRemoteImage
define("CIMAGE_USER_AGENT", "CImage/$version"); define("CIMAGE_USER_AGENT", "CImage/$version");

View File

@@ -23,7 +23,7 @@ return array(
* mode: 'production' * mode: 'production'
*/ */
//'mode' => 'production', //'mode' => 'production',
'mode' => 'development', //'mode' => 'development',
//'mode' => 'strict', //'mode' => 'strict',

View File

@@ -2022,7 +2022,13 @@ class CImage
$this->newWidth = round($factor * $width); $this->newWidth = round($factor * $width);
$this->log("New height was set."); $this->log("New height was set.");
} else {
// Use existing width and height as new width and height.
$this->newWidth = $width;
$this->newHeight = $height;
} }
// Get image dimensions for pre-resize image. // Get image dimensions for pre-resize image.
if ($this->cropToFit || $this->fillToFit) { if ($this->cropToFit || $this->fillToFit) {
@@ -2620,25 +2626,45 @@ class CImage
// Resize by crop to fit // Resize by crop to fit
$this->log("Resizing using strategy - Crop to fit"); $this->log("Resizing using strategy - Crop to fit");
if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight)) { if (!$this->upscale
&& ($this->width < $this->newWidth || $this->height < $this->newHeight)) {
$this->log("Resizing - smaller image, do not upscale."); $this->log("Resizing - smaller image, do not upscale.");
$cropX = round(($this->cropWidth/2) - ($this->newWidth/2)); //$cropX = round(($this->cropWidth/2) - ($this->width/2));
$cropY = round(($this->cropHeight/2) - ($this->newHeight/2)); //$cropY = round(($this->cropHeight/2) - ($this->height/2));
$posX = 0; $posX = 0;
$posY = 0; $posY = 0;
$cropX = 0;
$cropY = 0;
if ($this->newWidth > $this->width) { if ($this->newWidth > $this->width) {
$posX = round(($this->newWidth - $this->width) / 2); $posX = round(($this->newWidth - $this->width) / 2);
} }
if ($this->newWidth < $this->width) {
$cropX = round(($this->width/2) - ($this->newWidth/2));
}
if ($this->newHeight > $this->height) { if ($this->newHeight > $this->height) {
$posY = round(($this->newHeight - $this->height) / 2); $posY = round(($this->newHeight - $this->height) / 2);
} }
if ($this->newHeight < $this->height) {
$cropY = round(($this->height/2) - ($this->newHeight/2));
}
$this->log(" cwidth: $this->cropWidth");
$this->log(" cheight: $this->cropHeight");
$this->log(" nwidth: $this->newWidth");
$this->log(" nheight: $this->newHeight");
$this->log(" width: $this->width");
$this->log(" height: $this->height");
$this->log(" posX: $posX");
$this->log(" posY: $posY");
$this->log(" cropX: $cropX");
$this->log(" cropY: $cropY");
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight); //imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);
imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);
} else { } else {
$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));
@@ -2671,14 +2697,14 @@ class CImage
} }
if (!$this->upscale if (!$this->upscale
&& ($this->width < $this->newWidth || $this->height < $this->newHeight) && ($this->width < $this->newWidth && $this->height < $this->newHeight)
) { ) {
$this->log("Resizing - smaller image, do not upscale."); $this->log("Resizing - smaller image, do not upscale.");
$posX = round(($this->fillWidth - $this->width) / 2); $posX = round(($this->newWidth - $this->width) / 2);
$posY = round(($this->fillHeight - $this->height) / 2); $posY = round(($this->newHeight - $this->height) / 2);
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight); imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);
} else { } else {
$imgPreFill = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight); $imgPreFill = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);
@@ -2722,7 +2748,7 @@ class CImage
//$this->log("posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY."); //$this->log("posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY.");
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight); imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);
$this->image = $imageResized; $this->image = $imageResized;
$this->width = $this->newWidth; $this->width = $this->newWidth;
$this->height = $this->newHeight; $this->height = $this->newHeight;

View File

@@ -2022,7 +2022,13 @@ class CImage
$this->newWidth = round($factor * $width); $this->newWidth = round($factor * $width);
$this->log("New height was set."); $this->log("New height was set.");
} else {
// Use existing width and height as new width and height.
$this->newWidth = $width;
$this->newHeight = $height;
} }
// Get image dimensions for pre-resize image. // Get image dimensions for pre-resize image.
if ($this->cropToFit || $this->fillToFit) { if ($this->cropToFit || $this->fillToFit) {
@@ -2620,25 +2626,45 @@ class CImage
// Resize by crop to fit // Resize by crop to fit
$this->log("Resizing using strategy - Crop to fit"); $this->log("Resizing using strategy - Crop to fit");
if (!$this->upscale && ($this->width < $this->newWidth || $this->height < $this->newHeight)) { if (!$this->upscale
&& ($this->width < $this->newWidth || $this->height < $this->newHeight)) {
$this->log("Resizing - smaller image, do not upscale."); $this->log("Resizing - smaller image, do not upscale.");
$cropX = round(($this->cropWidth/2) - ($this->newWidth/2)); //$cropX = round(($this->cropWidth/2) - ($this->width/2));
$cropY = round(($this->cropHeight/2) - ($this->newHeight/2)); //$cropY = round(($this->cropHeight/2) - ($this->height/2));
$posX = 0; $posX = 0;
$posY = 0; $posY = 0;
$cropX = 0;
$cropY = 0;
if ($this->newWidth > $this->width) { if ($this->newWidth > $this->width) {
$posX = round(($this->newWidth - $this->width) / 2); $posX = round(($this->newWidth - $this->width) / 2);
} }
if ($this->newWidth < $this->width) {
$cropX = round(($this->width/2) - ($this->newWidth/2));
}
if ($this->newHeight > $this->height) { if ($this->newHeight > $this->height) {
$posY = round(($this->newHeight - $this->height) / 2); $posY = round(($this->newHeight - $this->height) / 2);
} }
if ($this->newHeight < $this->height) {
$cropY = round(($this->height/2) - ($this->newHeight/2));
}
$this->log(" cwidth: $this->cropWidth");
$this->log(" cheight: $this->cropHeight");
$this->log(" nwidth: $this->newWidth");
$this->log(" nheight: $this->newHeight");
$this->log(" width: $this->width");
$this->log(" height: $this->height");
$this->log(" posX: $posX");
$this->log(" posY: $posY");
$this->log(" cropX: $cropX");
$this->log(" cropY: $cropY");
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight); //imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);
imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);
} else { } else {
$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));
@@ -2671,14 +2697,14 @@ class CImage
} }
if (!$this->upscale if (!$this->upscale
&& ($this->width < $this->newWidth || $this->height < $this->newHeight) && ($this->width < $this->newWidth && $this->height < $this->newHeight)
) { ) {
$this->log("Resizing - smaller image, do not upscale."); $this->log("Resizing - smaller image, do not upscale.");
$posX = round(($this->fillWidth - $this->width) / 2); $posX = round(($this->newWidth - $this->width) / 2);
$posY = round(($this->fillHeight - $this->height) / 2); $posY = round(($this->newHeight - $this->height) / 2);
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->fillWidth, $this->fillHeight); imagecopy($imageResized, $this->image, $posX, $posY, 0, 0, $this->width, $this->height);
} else { } else {
$imgPreFill = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight); $imgPreFill = $this->CreateImageKeepTransparency($this->fillWidth, $this->fillHeight);
@@ -2722,7 +2748,7 @@ class CImage
//$this->log("posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY."); //$this->log("posX=$posX, posY=$posY, cropX=$cropX, cropY=$cropY.");
$imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight); $imageResized = $this->CreateImageKeepTransparency($this->newWidth, $this->newHeight);
imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->newWidth, $this->newHeight); imagecopy($imageResized, $this->image, $posX, $posY, $cropX, $cropY, $this->width, $this->height);
$this->image = $imageResized; $this->image = $imageResized;
$this->width = $this->newWidth; $this->width = $this->newWidth;
$this->height = $this->newHeight; $this->height = $this->newHeight;

File diff suppressed because one or more lines are too long