• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Animated Image scaling bug

Jeremy

Well-known member
#2
This is a bug in the ImageMagick or GD (I'm not sure which one you are using) and not XenForo. What image processor are you using?
 
#3
I use the GD. ImageMagick not installed.
If you are sure that the case in the library then I apologize. Not even think to check it.
Be sure to check ImageMagick, thank you for your help.
 
#4
ImageMagick library must use an extra key when working with GIF images.
See below:
PHP:
function imageapi_imagemagick_image_resize(&$image, $width, $height) {

  $extra = '';
  if($image->info['mime_type'] == 'image/gif') {
    $extra = '-coalesce ';
  }
  $image->ops[] = $extra . '-resize '. (int) $width .'x'. (int) $height .'!';
  $image->info['width'] = $width;
  $image->info['height'] = $height;
  return TRUE;
}
Note: This code is used in the system Drupal
I did not find this in the code XenForo.
Also, when operating with the library is converting animated GIF to IMG, which as I understand it should not be.

P.S. Sorry for my bad english :)
 
#6
How's that option?
PHP:
$image = new Imagick('myfile.gif');
$image = $image->coalesceimages();

$final = new \Imagick();
foreach ($image as $frame){
    $image->thumbnailImage($width, $height, true);
    $geometry = $image->getImageGeometry();
    $x = ( $width - $geometry['width'] ) / 2;
    $y = ( $height - $geometry['height'] ) / 2;
    $canvas = new \Imagick();
    $canvas->newImage( $width, $height, $background);
    $canvas->compositeImage( $image, \Imagick::COMPOSITE_OVER, $x, $y );
    $final->addimage($canvas);
}
$final = $final->optimizedImageLayers();
$final->writeImages('resized.gif', true);