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

The `-ping` option significantly speeds up the ImageMagick `identify` command per our testing and the [documentation](https://imagemagick.org/script/command-line-options.php#ping):

> -ping
Efficiently determine these image characteristics: image number, the file name, the width and height of the image, whether the image is colormapped or not, the number of colors in the image, the number of bytes in the image, the format of the image (JPEG, PNM, etc.). Use +ping to ensure accurate image properties.

We already pass the `-ping` option in other places where the `identify` command is used, so it makes sense to use the option everywhere.

Internal topic: t/121431.
This commit is contained in:
Osama Sayegh
2024-02-15 18:55:39 +03:00
committed by GitHub
parent 4deacc4aa8
commit cfdb461e9a
2 changed files with 2 additions and 1 deletions

View File

@ -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