Merge pull request #507 from fermionic/imagick-profile-photos-squashed
use getWidth and getHeight, which are agnostic to Imagick being enabled
This commit is contained in:
commit
1c66fed5c4
1 changed files with 33 additions and 31 deletions
|
@ -129,11 +129,12 @@ class Photo {
|
||||||
$this->image->setCompressionQuality($quality);
|
$this->image->setCompressionQuality($quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->width = $this->image->getImageWidth();
|
// The 'width' and 'height' properties are only used by non-Imagick routines.
|
||||||
|
$this->width = $this->image->getImageWidth();
|
||||||
$this->height = $this->image->getImageHeight();
|
$this->height = $this->image->getImageHeight();
|
||||||
$this->valid = true;
|
$this->valid = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->valid = false;
|
$this->valid = false;
|
||||||
|
@ -205,8 +206,8 @@ class Photo {
|
||||||
if(!$this->is_valid())
|
if(!$this->is_valid())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
$width = $this->width;
|
$width = $this->getWidth();
|
||||||
$height = $this->height;
|
$height = $this->getHeight();
|
||||||
|
|
||||||
$dest_width = $dest_height = 0;
|
$dest_width = $dest_height = 0;
|
||||||
|
|
||||||
|
@ -263,24 +264,25 @@ class Photo {
|
||||||
|
|
||||||
|
|
||||||
if($this->is_imagick()) {
|
if($this->is_imagick()) {
|
||||||
/**
|
/**
|
||||||
* If it is not animated, there will be only one iteration here,
|
* If it is not animated, there will be only one iteration here,
|
||||||
* so don't bother checking
|
* so don't bother checking
|
||||||
*/
|
*/
|
||||||
// Don't forget to go back to the first frame
|
// Don't forget to go back to the first frame
|
||||||
$this->image->setFirstIterator();
|
$this->image->setFirstIterator();
|
||||||
do {
|
do {
|
||||||
|
|
||||||
// FIXME - implement horizantal bias for scaling as in followin GD functions
|
// FIXME - implement horizantal bias for scaling as in followin GD functions
|
||||||
// to allow very tall images to be constrained only horizontally.
|
// to allow very tall images to be constrained only horizontally.
|
||||||
|
|
||||||
$this->image->scaleImage($dest_width, $dest_height);
|
$this->image->scaleImage($dest_width, $dest_height);
|
||||||
} while ($this->image->nextImage());
|
} while ($this->image->nextImage());
|
||||||
|
|
||||||
// FIXME - also we need to copy the new dimensions to $this->height, $this->width as other functions
|
// These may not be necessary any more
|
||||||
// may rely on it.
|
$this->width = $this->image->getImageWidth();
|
||||||
|
$this->height = $this->image->getImageHeight();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -402,8 +404,8 @@ class Photo {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
||||||
$width = $this->width;
|
$width = $this->getWidth();
|
||||||
$height = $this->height;
|
$height = $this->getHeight();
|
||||||
|
|
||||||
$dest_width = $dest_height = 0;
|
$dest_width = $dest_height = 0;
|
||||||
|
|
||||||
|
@ -483,19 +485,19 @@ class Photo {
|
||||||
if(!$this->is_valid())
|
if(!$this->is_valid())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if($this->is_imagick()) {
|
if($this->is_imagick()) {
|
||||||
$this->image->setFirstIterator();
|
$this->image->setFirstIterator();
|
||||||
do {
|
do {
|
||||||
$this->image->cropImage($w, $h, $x, $y);
|
$this->image->cropImage($w, $h, $x, $y);
|
||||||
/**
|
/**
|
||||||
* We need to remove the canva,
|
* We need to remove the canva,
|
||||||
* or the image is not resized to the crop:
|
* or the image is not resized to the crop:
|
||||||
* http://php.net/manual/en/imagick.cropimage.php#97232
|
* http://php.net/manual/en/imagick.cropimage.php#97232
|
||||||
*/
|
*/
|
||||||
$this->image->setImagePage(0, 0, 0, 0);
|
$this->image->setImagePage(0, 0, 0, 0);
|
||||||
} while ($this->image->nextImage());
|
} while ($this->image->nextImage());
|
||||||
return $this->scaleImage($max);
|
return $this->scaleImage($max);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dest = imagecreatetruecolor( $max, $max );
|
$dest = imagecreatetruecolor( $max, $max );
|
||||||
imagealphablending($dest, false);
|
imagealphablending($dest, false);
|
||||||
|
|
Loading…
Reference in a new issue