consistent handling of scaled images when using imagick

This commit is contained in:
friendica 2012-09-30 03:25:20 -07:00
parent 84199e6e71
commit 112fafcc81
2 changed files with 26 additions and 24 deletions

View file

@ -205,27 +205,6 @@ class Photo {
if(!$this->is_valid()) if(!$this->is_valid())
return FALSE; return FALSE;
if($this->is_imagick()) {
/**
* If it is not animated, there will be only one iteration here,
* so don't bother checking
*/
// Don't forget to go back to the first frame
$this->image->setFirstIterator();
do {
// FIXME - implement horizantal bias for scaling as in followin GD functions
// to allow very tall images to be constrained only horizontally.
$this->image->resizeImage($max, $max, imagick::FILTER_LANCZOS, 1, true);
} while ($this->image->nextImage());
// FIXME - also we need to copy the new dimensions to $this->height, $this->width as other functions
// may rely on it.
return;
}
$width = $this->width; $width = $this->width;
$height = $this->height; $height = $this->height;
@ -283,6 +262,28 @@ class Photo {
} }
if($this->is_imagick()) {
/**
* If it is not animated, there will be only one iteration here,
* so don't bother checking
*/
// Don't forget to go back to the first frame
$this->image->setFirstIterator();
do {
// FIXME - implement horizantal bias for scaling as in followin GD functions
// to allow very tall images to be constrained only horizontally.
$this->image->scaleImage($dest_width, $dest_height);
} while ($this->image->nextImage());
// FIXME - also we need to copy the new dimensions to $this->height, $this->width as other functions
// may rely on it.
return;
}
$dest = imagecreatetruecolor( $dest_width, $dest_height ); $dest = imagecreatetruecolor( $dest_width, $dest_height );
imagealphablending($dest, false); imagealphablending($dest, false);
imagesavealpha($dest, true); imagesavealpha($dest, true);
@ -400,8 +401,6 @@ class Photo {
if(!$this->is_valid()) if(!$this->is_valid())
return FALSE; return FALSE;
if($this->is_imagick())
return $this->scaleImage($min);
$width = $this->width; $width = $this->width;
$height = $this->height; $height = $this->height;
@ -438,6 +437,8 @@ class Photo {
} }
} }
if($this->is_imagick())
return $this->scaleImage($dest_width,$dest_height);
$dest = imagecreatetruecolor( $dest_width, $dest_height ); $dest = imagecreatetruecolor( $dest_width, $dest_height );
imagealphablending($dest, false); imagealphablending($dest, false);
@ -460,7 +461,7 @@ class Photo {
if($this->is_imagick()) { if($this->is_imagick()) {
$this->image->setFirstIterator(); $this->image->setFirstIterator();
do { do {
$this->image->resizeImage($dim, $dim, imagick::FILTER_LANCZOS, 1, false); $this->image->scaleImage($dim, $dim);
} while ($this->image->nextImage()); } while ($this->image->nextImage());
return; return;
} }

View file

@ -994,6 +994,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
intval($tagcid), intval($tagcid),
intval($profile_uid) intval($profile_uid)
); );
}
else { else {
$newname = str_replace('_',' ',$name); $newname = str_replace('_',' ',$name);