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

XF 1.4 Image Quality on Resize?

Discussion in 'XenForo Questions and Support' started by nrep, Feb 7, 2015.

  1. nrep

    nrep Well-Known Member

    If I set max dimensions for an image upload, any image that exceeds this is automatically resized. Is there somewhere to set the image quality of the resized image, or is it hard coded?

    If it's hard coded, what is it? - does anyone know? :)
  2. Brogan

    Brogan XenForo Moderator Staff Member

    It's hard coded.

    I haven't checked but I believe it may be 85%.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Assuming you are using the GD library:


    You probably can't change the default value in the function signature because of the abstract. But this should work:

    	 * Outputs the image.
    	 * @see XenForo_Image_Abstract::output()
    	public function output($outputType, $outputFile = null, $quality = 85)
    		if ($quality == 85)
    			$quality = 90;
    		switch ($outputType)
    			case IMAGETYPE_GIF: $success = imagegif($this->_image, $outputFile); break;
    			case IMAGETYPE_JPEG: $success = imagejpeg($this->_image, $outputFile, $quality); break;
    			case IMAGETYPE_PNG:
    				// "quality" seems to be misleading, always force 9
    				$success = imagepng($this->_image, $outputFile, 9, PNG_ALL_FILTERS);
    				throw new XenForo_Exception('Invalid output type given. Expects IMAGETYPE_XXX constant.');
    		return $success;

Share This Page