Fixed Save original avatar file with higher JPEG quality than 85

Steffen

Well-known member
Affected version
2.0.4
If a user uploads an avatar file that is larger than 384x384 pixels then XenForo resizes it to 384x384 pixels. If it is a JPEG file then it is saved with quality 85 (like all other JPEG images). I think the original avatar file should get a special treatment and use a very high JPEG quality because it's only (?) purpose seems to be serving as the source for (re-)building other avatar files. Since this is a very easy fix I thought that you might want to consider it (although it's probably not strictly a bug).

Diff:
diff --git a/src/XF/Service/User/Avatar.php b/src/XF/Service/User/Avatar.php
index 75d8bd017..d7c2468e0 100644
--- a/src/XF/Service/User/Avatar.php
+++ b/src/XF/Service/User/Avatar.php
@@ -240,7 +240,7 @@ class Avatar extends \XF\Service\AbstractService
             $image->resizeShortEdge($origSize);
 
             $newTempFile = \XF\Util\File::getTempFile();
-            if ($newTempFile && $image->save($newTempFile))
+            if ($newTempFile && $image->save($newTempFile, null, 95))
             {
                 $outputFiles['o'] = $newTempFile;
                 $baseFile = $newTempFile;
 
Back
Top Bottom