[pLog-svn] r3827 - plog/trunk/class/gallery/resizers
mark at devel.lifetype.net
mark at devel.lifetype.net
Mon Jul 31 07:07:46 GMT 2006
Author: mark
Date: 2006-07-31 07:07:44 +0000 (Mon, 31 Jul 2006)
New Revision: 3827
Modified:
plog/trunk/class/gallery/resizers/gallerygdresizer.class.php
Log:
Fixed a bug that caused by commit 3795.
Modified: plog/trunk/class/gallery/resizers/gallerygdresizer.class.php
===================================================================
--- plog/trunk/class/gallery/resizers/gallerygdresizer.class.php 2006-07-31 04:24:58 UTC (rev 3826)
+++ plog/trunk/class/gallery/resizers/gallerygdresizer.class.php 2006-07-31 07:07:44 UTC (rev 3827)
@@ -211,8 +211,17 @@
$src_y, $dst_w, $dst_h, $src_w, $src_h,
$resample = GD_RESIZER_NO_SMOOTHING_MODE ) {
$pxls = intval($src_w / $dst_w)-1;
+
+ if( $dst_w == $dst_h ) {
+ $length = min($src_w, $src_h);
+ $src_x = intval( $src_w / 2 ) - intval( $length / 2 );
+ $src_y = intval( $src_h / 2 ) - intval( $length / 2 );
+ $src_w = $length;
+ $src_h = $length;
+ }
+
if( $resample == GD_RESIZER_PHP_IMAGECOPYRESAMPLED ) {
- imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
+ imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
}
elseif( $resample == GD_RESIZER_BILINEAR_MODE ) { //slow but better quality
ImageTrueColorToPalette( $src_img, false, 256 );
@@ -276,7 +285,7 @@
{
$fileParts = explode( ".", $save );
$fileNoExt = implode( ".", $fileParts );
- $fileExt = $fileParts[count($fileParts)-1];
+ $fileExt = strtolower($fileParts[count($fileParts)-1]);
//if( function_exists("imagecreatetruecolor")) {
if( $this->isGD2Available()) {
@@ -323,16 +332,17 @@
$ratioimg = (float) $this->img["lebar"] / (float) $this->img["tinggi"];
$ratiothumb=(float) $width / (float) $height;
-
- if ($ratioimg == $ratiothumb){
+ if ($ratioimg == $ratiothumb || $ratiothumb == (float) 1){
$this->img["lebar_thumb"]=$width;
$this->img["tinggi_thumb"]=$height;
} elseif ($ratioimg > $ratiothumb){
- $this->img["lebar_thumb"]=$width;
- $this->img["tinggi_thumb"]=$width*((float)1/$ratioimg);
+ $length = max($width, $height);
+ $this->img["lebar_thumb"]=$length;
+ $this->img["tinggi_thumb"]=$length*((float)1/$ratioimg);
} elseif ($ratioimg < $ratiothumb){
- $this->img["tinggi_thumb"]=$height;
- $this->img["lebar_thumb"]=$height*$ratioimg;
+ $length = max($width, $height);
+ $this->img["tinggi_thumb"]=$length;
+ $this->img["lebar_thumb"]=$length*$ratioimg;
}
}
More information about the pLog-svn
mailing list