mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:38:17 +08:00
FIX: automatic PNG-to-JPEG conversion should use a default white background
This commit is contained in:
parent
c4b6420455
commit
832d621b48
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user