Skip to content

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

PERF: Pass the `-ping` option to the `identify` ImageMagick command to speed it up (#25697)

Osama Sayeghcfdb461e9a4e
diff --git a/app/models/upload.rb b/app/models/upload.rb
index e1fda0ead3a..5b02962a3a4 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -281,6 +281,7 @@ class Upload < ActiveRecord::Base
begin
Discourse::Utils.execute_command(
"identify",
+ "-ping",
"-format",
"%w %h",
path,
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb
index c992c285c12..36647f0ba2b 100644
--- a/lib/upload_creator.rb
+++ b/lib/upload_creator.rb
@@ -663,7 +663,7 @@ class UploadCreator
# Only GIFs, WEBPs and a few other unsupported image types can be animated
OptimizedImage.ensure_safe_paths!(@file.path)
- command = ["identify", "-format", "%n\\n", @file.path]
+ command = ["identify", "-ping", "-format", "%n\\n", @file.path]
frames =
begin
Discourse::Utils.execute_command(*command, timeout: Upload::MAX_IDENTIFY_SECONDS).to_i