- if((! $width)|| (! $height))
- return FALSE;
-
- if($width < $min && $height < $min) {
- if($width > $height) {
- $dest_width = $min;
- $dest_height = intval(( $height * $min ) / $width);
- }
- else {
- $dest_width = intval(( $width * $min ) / $height);
- $dest_height = $min;
- }
- }
- else {
- if( $width < $min ) {
- $dest_width = $min;
- $dest_height = intval(( $height * $min ) / $width);
- }
- else {
- if( $height < $min ) {
- $dest_width = intval(( $width * $min ) / $height);
- $dest_height = $min;
- }
- else {
- $dest_width = $width;
- $dest_height = $height;
- }
- }
- }
-
- if($this->is_imagick())
- return $this->scaleImage($dest_width,$dest_height);
-
- $dest = imagecreatetruecolor( $dest_width, $dest_height );
- imagealphablending($dest, false);
- imagesavealpha($dest, true);
- if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
- imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
- if($this->image)
- imagedestroy($this->image);
- $this->image = $dest;
- $this->width = imagesx($this->image);
- $this->height = imagesy($this->image);
- }
-
-
-
- public function scaleImageSquare($dim) {
- if(!$this->is_valid())
- return FALSE;
-
- if($this->is_imagick()) {
- $this->image->setFirstIterator();
- do {
- $this->image->scaleImage($dim, $dim);
- } while ($this->image->nextImage());
- return;
- }
-
- $dest = imagecreatetruecolor( $dim, $dim );
- imagealphablending($dest, false);
- imagesavealpha($dest, true);
- if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
- imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
- if($this->image)
- imagedestroy($this->image);
- $this->image = $dest;
- $this->width = imagesx($this->image);
- $this->height = imagesy($this->image);
- }
-
-
- public function cropImage($max,$x,$y,$w,$h) {
- if(!$this->is_valid())
- return FALSE;
-
- if($this->is_imagick()) {
+ $dest = imagecreatetruecolor($dim, $dim);
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ if ($this->type=='image/png') {
+ imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
+ }
+ imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
+ if ($this->image) {
+ imagedestroy($this->image);
+ }
+ $this->image = $dest;
+ $this->width = imagesx($this->image);
+ $this->height = imagesy($this->image);
+ }
+
+
+ public function cropImage($max, $x, $y, $w, $h) {
+ if (!$this->is_valid()) {
+ return false;
+ }
+
+ if ($this->is_imagick()) {