-
ImageMagick version7.1.1-31 Operating system, version and so onAndroid 7.1.2 (Termux) DescriptionWhy is ImageMagick much slower than ffmpeg in processing (scaling, changing color space) images? The output file size also increases by around 10% to 30%. When converting the same image to YUV420 format, ImageMagick, at its default quality of 92, produces files that are at least 10% larger than FFmpeg's lossless quality (calculated as quality 94 with identify -verbose), and the processing time is almost twice as long. I used the compare tool to compare the two converted images. Close to half or maybe even more than half of the pixels are somewhat different. However, visually or using a comparison method with a certain tolerance (15%), except for a few pixels, they are basically identical. Here is ImageMagick options: convert \
-colorspace "YUV" \
-depth "8" \
-interlace "none" \
-limit memory "${memory}K" \
-limit thread "${thread}" \
-quality "$quality" \
-resize "$resize_" \
-sampling-factor "2x2,1x1,1x1" \
-- "$file_" "$temp_dir/$file__" The output format is jpg. Here, the value of $quality is mostly 0, for jpg, it equals 92. And ffmpeg options: ffmpeg \
-i "$file_" \
-preset placebo \
-q:v 0 \
-vf "format=yuv420p,scale='$resize_':-1" \
"$temp_dir/$file__" |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Why are you using the old v6 syntax for IM? Why not use the v7 syntax? Limiting memory and threads will decrease performance. Are you comparing like with like? Perhaps your IM calculates in floating-point, and ffmpeg uses integer? Comparing the outputs from each gives no useful information. Instead, you might compare both outputs to a ground truth, which would tell you which output is more correct. If you are only resizing jpegs, you may find that a specialist jpeg program is faster than either IM or ffmpeg. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply.
I opted for compatibility with v6 in the script. In most cases, using v6 syntax under v7 doesn't pose significant issues.
Yes, but that's not the critical issue. In my task, these limitations are within reasonable bounds.
Sorry, I'm not very knowledgeable about this. If that's the case, is there a way to optimize it? Or to make IM compatible with integer mode?
Well, correctness is important too. But having options to sacrifice some correctness for faster conversion would be beneficial...
Perhaps. Can you recommend some? Thank you for your reply again. |
Beta Was this translation helpful? Give feedback.
-
Commands can be written that will work identically in v6 or v7 syntax. Writing them to work only in v6 seems a strange choice. IM can be built to do the calculations in integer or floating-point. If building with IM has multiple methods for resampling images, including I rarely resize jpegs, and never for serious work. Jpeg is a useful output-only format, and a terrible format for inputs to any image processing. |
Beta Was this translation helpful? Give feedback.
-
Okay. Also, I just noticed that these comments are highlighted in the NEWS section of the README:
My bad for not checking the README for a long time. |
Beta Was this translation helpful? Give feedback.
Commands can be written that will work identically in v6 or v7 syntax. Writing them to work only in v6 seems a strange choice.
IM can be built to do the calculations in integer or floating-point. If building with
./configure
bash script, the--enable-hdri
option uses floating-point.IM has multiple methods for resampling images, including
-resize
,-scale
and-sample
, in order of decreasing quality and increasing speed.I rarely resize jpegs, and never for serious work. Jpeg is a useful output-only format, and a terrible format for inputs to any image processing.