mirror of
https://github.com/discourse/discourse.git
synced 2025-05-02 06:14:35 +08:00
FIX: automatic PNG-to-JPEG conversion should use a default white background
This commit is contained in:
parent
d1b06624ff
commit
a64ef19e39
@ -132,7 +132,13 @@ class UploadCreator
|
|||||||
jpeg_tempfile = Tempfile.new(["image", ".jpg"])
|
jpeg_tempfile = Tempfile.new(["image", ".jpg"])
|
||||||
|
|
||||||
OptimizedImage.ensure_safe_paths!(@file.path, jpeg_tempfile.path)
|
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
|
# keep the JPEG if it's at least 15% smaller
|
||||||
if File.size(jpeg_tempfile.path) < filesize * 0.85
|
if File.size(jpeg_tempfile.path) < filesize * 0.85
|
||||||
|
Loading…
x
Reference in New Issue
Block a user