From a64ef19e39a7cbb13b5ec2fbe07aa32133911f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 1 Jun 2017 23:10:36 +0200 Subject: [PATCH] FIX: automatic PNG-to-JPEG conversion should use a default white background --- lib/upload_creator.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb index c47afd4a1f4..1a9b5774205 100644 --- a/lib/upload_creator.rb +++ b/lib/upload_creator.rb @@ -132,7 +132,13 @@ class UploadCreator jpeg_tempfile = Tempfile.new(["image", ".jpg"]) OptimizedImage.ensure_safe_paths!(@file.path, jpeg_tempfile.path) - Discourse::Utils.execute_command('convert', @file.path, '-quality', SiteSetting.png_to_jpg_quality.to_s, jpeg_tempfile.path) + Discourse::Utils.execute_command( + 'convert', @file.path, + '-background', 'white', + '-flatten', + '-quality', SiteSetting.png_to_jpg_quality.to_s, + jpeg_tempfile.path + ) # keep the JPEG if it's at least 15% smaller if File.size(jpeg_tempfile.path) < filesize * 0.85