XF 1.4 Image Quality on Resize?

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? :)
 
Assuming you are using the GD library:

library/XenForo/Image/Gd.php

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

Rich (BB code):
	/**
	 * 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);
				break;

			default:
				throw new XenForo_Exception('Invalid output type given. Expects IMAGETYPE_XXX constant.');
		}

		return $success;
	}
 
Back
Top Bottom