Skip to content

A platform for community discussion. Free, open, simple.

PERF: Use `-ping` option to ImageMagick `identify` command (#25713)

Alan Guo Xiang Tancc9480b24af1
diff --git a/app/models/upload.rb b/app/models/upload.rb
index 5b02962a3a4..665ac847ed3 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -414,6 +414,7 @@ class Upload < ActiveRecord::Base
begin
Discourse::Utils.execute_command(
"identify",
+ "-ping",
"-format",
"%Q",
local_path,
diff --git a/spec/lib/upload_creator_spec.rb b/spec/lib/upload_creator_spec.rb
index a340c029aa6..e6f93f20fba 100644
--- a/spec/lib/upload_creator_spec.rb
+++ b/spec/lib/upload_creator_spec.rb
@@ -147,7 +147,7 @@ RSpec.describe UploadCreator do
describe "converting to jpeg" do
def image_quality(path)
local_path = File.join(Rails.root, "public", path)
- Discourse::Utils.execute_command("identify", "-format", "%Q", local_path).to_i
+ Discourse::Utils.execute_command("identify", "-ping", "-format", "%Q", local_path).to_i
end
let(:filename) { "should_be_jpeg.png" }