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

Fixed Uploaded avatar will not be scaled using Imagicks

Discussion in 'Resolved Bug Reports' started by sonnb, Nov 28, 2013.

  1. sonnb

    sonnb Well-Known Member

    When using Imagick, although the avatar uploading preview shows the scaled avatar and allow us to drap around but when click save, the avatar will not be scaled but just cropped. It will work if I switch back to GD.

    Anyone experiencing this?
     
    bortrenamo likes this.
  2. Mike

    Mike XenForo Developer Staff Member

    This works correctly for me. What version of the imagick PECL extension are you using? (And what version of ImageMagick is that using?) It's possible there's a regression in the library.
     
  3. sonnb

    sonnb Well-Known Member

    This is the information:

    upload_2013-11-30_1-5-38.png
     
  4. Mike

    Mike XenForo Developer Staff Member

    There was another report of it here and it seemed to be image specific: http://xenforo.com/community/threads/size-of-avatar.64331/#post-679293

    I have just found an issue if you're using an old imagick module version - pre-3.0 - as it will fail because of an argument that isn't expected. I'm trying to figure out how to detect that as it's needed for another imagick quirk. However, based on your phpinfo, I don't think that should be affecting you.
     
  5. Mike

    Mike XenForo Developer Staff Member

    Can you try adding the code in green to library/XenForo/Image/ImageMagick/Pecl.php:
    Code:
            $oldImagick = version_compare(phpversion('imagick'), '3', '<');
    
            try
            {
                foreach ($this->_image AS $frame)
                {
                    if ($scaleUp)
                    {
                        $frame->resizeImage($width, $height, Imagick::FILTER_QUADRATIC, .5, true);
                    }
                    else if ($oldImagick)
                    {
                        // the fill param wasn't added until imagick 3.0 so we can't pass it without an error
                        $frame->thumbnailImage($width, $height, true);
                    }
                    else
                    {
                        $frame->thumbnailImage($width, $height, true, true);
                    }
                    $frame->setImagePage($width, $height, 0, 0);
                }
    
                $this->_updateDimensionCache();
            }
            catch (Exception $e)
            {
                XenForo_Error::logException($e, false);
                return false;
            }
    And then try adding an image that failed before. Is it working now? If not, check the server error log - is anything logged?
     
    Adam Howard likes this.
  6. sonnb

    sonnb Well-Known Member

    Sure. I will try it and report back later.
     
  7. sonnb

    sonnb Well-Known Member

    The error is:
     
    Adam Howard likes this.
  8. Mike

    Mike XenForo Developer Staff Member

    Well that's annoying (and undocumented I think...). I think it can be worked around though.
     
    Adam Howard and sonnb like this.
  9. Ark Royal

    Ark Royal Active Member

    As requested from the other thread.
    Capture.JPG
     
    Adam Howard likes this.
  10. Mike

    Mike XenForo Developer Staff Member

    The fix above should work for you then.
     
  11. Ark Royal

    Ark Royal Active Member

    I'll give it a go.
    Thanks for the help.
     
  12. Ark Royal

    Ark Royal Active Member

    Thanks @Mike fix works :)
     
  13. Mike

    Mike XenForo Developer Staff Member

    I've detected the ImageMagick version now as well for this.
     
    yavuz and sonnb like this.

Share This Page