imazen / imageflow

High-performance image manipulation for web servers. Includes imageflow_server, imageflow_tool, and libimageflow
https://docs.imageflow.io/
GNU Affero General Public License v3.0
4.14k stars 140 forks source link

too much time on a medium size file #623

Closed bes-internal closed 1 year ago

bes-internal commented 1 year ago
$ identify orig.jpg
orig.jpg JPEG 2560x3589 2560x3589+0+0 8-bit sRGB 5251070B 0.000u 0:00.000
$ time magick convert -quality 88 -resize 3000x\> orig.jpg im.jpg
real    0m0.436s
user    0m0.394s
sys     0m0.037s
$ time imageflow_tool v1/querystring --in orig.jpg --out imageflow.jpg --command "width=3000&format=jpeg&quality=88" --quiet
real    0m3.234s <--
user    0m3.166s
sys     0m0.056s

====

$ imageflow_tool --version
imageflow_tool release 2.0.0-preview4 (22a2bf99f 2023-01-06) for x86_64-unknown-linux-gnu 

Debug package imageflow-2.0.0-p4.zip

lilith commented 1 year ago

That's horrifically slow! Can you share the exact image you were processing? Are you running this under WSL or directly?

bes-internal commented 1 year ago

Please see provided Debug package archive! Directly on Linux home 5.10.135-gentoo-dist #1 SMP x86_64 Intel(R) Core(TM) i3-7350K CPU @ 4.20GHz GenuineIntel GNU/Linux

lilith commented 1 year ago

Oops, I missed that the first time I extracted the archive. Thanks!

lilith commented 1 year ago

Hmm, so I can reproduce this pathological behavior with that image even on windows (1.6 seconds). It appears that something in the encoder is taking a slow path with this bitmap data, because an identically sized jpeg that is a normal photograph takes .221 seconds to re-encode.

It's likely that this is a problem with mozjpeg - it does take more time to optimize images than libjpeg-turbo, and perhaps something in this odd image is causing pathological behavior.

input_0_orig