From 6dac9075dcb45bd61cf1addae45b26fbd5024983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 27 Jul 2016 19:59:44 +0200 Subject: [PATCH] new 'convert_pasted_images_quality' site setting --- app/controllers/uploads_controller.rb | 2 +- config/locales/server.en.yml | 1 + config/site_settings.yml | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 70119a21019..95413db5a42 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -73,7 +73,7 @@ class UploadsController < ApplicationController # convert pasted images to HQ jpegs if filename == "blob.png" && SiteSetting.convert_pasted_images_to_hq_jpg jpeg_path = "#{File.dirname(tempfile.path)}/blob.jpg" - `convert #{tempfile.path} -quality 95 #{jpeg_path}` + `convert #{tempfile.path} -quality #{SiteSetting.convert_pasted_images_quality} #{jpeg_path}` # only change the format of the image when JPG is at least 5% smaller if File.size(jpeg_path) < File.size(tempfile.path) * 0.95 filename = "blob.jpg" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d409149c888..a3ffb33f877 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1070,6 +1070,7 @@ en: allow_all_attachments_for_group_messages: "Allow all email attachments for group messages." convert_pasted_images_to_hq_jpg: "Convert pasted images to high-quality JPG files." + convert_pasted_images_quality: "Quality of the converted JPG file (1 is lowest quality, 100 is best quality)." enable_flash_video_onebox: "Enable embedding of swf and flv (Adobe Flash) links in oneboxes. WARNING: may introduce security risks." diff --git a/config/site_settings.yml b/config/site_settings.yml index 35bf337a935..db4da760835 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -718,6 +718,10 @@ files: default_opengraph_image_url: '' allow_all_attachments_for_group_messages: false convert_pasted_images_to_hq_jpg: true + convert_pasted_images_quality: + default: 95 + min: 1 + max: 100 trust: default_trust_level: