core-imaging-playground icon indicating copy to clipboard operation
core-imaging-playground copied to clipboard

Added ImageFlow-dotnet

Open MichaelSorensen opened this issue 3 years ago β€’ 4 comments

Added this cross platform image optimizing library to the benchmarks. Don't actually know that much about the library, but needed to test it out for a project.

Link to repo: ImageFlow-dotnet

MichaelSorensen avatar Oct 28 '22 21:10 MichaelSorensen

I tried to do this a while back but couldn't figure out the API. How does it fair?

JimBobSquarePants avatar Oct 28 '22 23:10 JimBobSquarePants

Thanks for this! I've been curious about ImageFlow myself, but not quite curious enough to figure it out πŸ˜…

Looks like they don't have Arm binaries, so can you add a filter for it? Would go here:

https://github.com/bleroy/core-imaging-playground/blob/8ebb9d20031bb80affdd80c5e10e4672840f21f6/NetCore/Program.cs#L53-L57

saucecontrol avatar Oct 29 '22 00:10 saucecontrol

Actually not really used it that much, and surely not enough to give an honest review :)

I tried to do this a while back but couldn't figure out the API. How does it fair?

MichaelSorensen avatar Oct 31 '22 09:10 MichaelSorensen

Thanks for this! I've been curious about ImageFlow myself, but not quite curious enough to figure it out πŸ˜…

Looks like they don't have Arm binaries, so can you add a filter for it? Would go here:

https://github.com/bleroy/core-imaging-playground/blob/8ebb9d20031bb80affdd80c5e10e4672840f21f6/NetCore/Program.cs#L53-L57

Sorry about that, I've changed to only run on x86/x64

MichaelSorensen avatar Oct 31 '22 09:10 MichaelSorensen

I pulled down this PR locally and updated the code from main plus all additional dependencies. Here's the benchmark results on my laptop. Performance is middling at best with the 3rd slowest processing time.

Load/Resize/Save

BenchmarkDotNet v0.13.8, Windows 11 (10.0.22621.2361/22H2/2022Update/SunValley2)
11th Gen Intel Core i7-11370H 3.30GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK 7.0.401
  [Host]   : .NET 7.0.11 (7.0.1123.42427), X64 RyuJIT AVX2
  ShortRun : .NET 7.0.11 (7.0.1123.42427), X64 RyuJIT AVX2

Job=ShortRun  Arguments=/p:DebugType=portable  IterationCount=5
LaunchCount=1  WarmupCount=5

| Method                              | Mean      | Error     | StdDev   | Ratio | Gen0      | Gen1      | Gen2      | Allocated | Alloc Ratio |
|------------------------------------ |----------:|----------:|---------:|------:|----------:|----------:|----------:|----------:|------------:|
| 'System.Drawing Load, Resize, Save' | 380.51 ms | 17.252 ms | 2.670 ms |  1.00 |         - |         - |         - |  13.33 KB |        1.00 |
| 'ImageFlow Load, Resize, Save'      | 283.12 ms | 16.081 ms | 4.176 ms |  0.75 |  500.0000 |  500.0000 |  500.0000 | 4645.1 KB |      348.52 |
| 'ImageSharp Load, Resize, Save'     | 126.59 ms | 12.328 ms | 3.202 ms |  0.33 |  250.0000 |  250.0000 |  250.0000 | 1608.3 KB |      120.67 |
| 'ImageSharp TD Load, Resize, Save'  |  79.66 ms |  5.845 ms | 1.518 ms |  0.21 |         - |         - |         - |  895.8 KB |       67.21 |
| 'ImageMagick Load, Resize, Save'    | 410.43 ms | 10.042 ms | 1.554 ms |  1.08 |         - |         - |         - |  55.27 KB |        4.15 |
| 'ImageFree Load, Resize, Save'      | 252.61 ms | 19.803 ms | 5.143 ms |  0.66 | 6000.0000 | 6000.0000 | 6000.0000 |  94.66 KB |        7.10 |
| 'MagicScaler Load, Resize, Save'    |  68.03 ms |  4.004 ms | 0.620 ms |  0.18 |         - |         - |         - |   61.4 KB |        4.61 |
| 'SkiaSharp Load, Resize, Save'      | 143.48 ms |  3.839 ms | 0.594 ms |  0.38 |         - |         - |         - | 118.84 KB |        8.92 |
| 'NetVips Load, Resize, Save'        | 150.62 ms |  7.408 ms | 1.924 ms |  0.40 |         - |         - |         - | 122.26 KB |        9.17 |

Resize

BenchmarkDotNet v0.13.8, Windows 11 (10.0.22621.2361/22H2/2022Update/SunValley2)
11th Gen Intel Core i7-11370H 3.30GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK 7.0.401
  [Host]   : .NET 7.0.11 (7.0.1123.42427), X64 RyuJIT AVX2
  ShortRun : .NET 7.0.11 (7.0.1123.42427), X64 RyuJIT AVX2

Job=ShortRun  Arguments=/p:DebugType=portable  IterationCount=5
LaunchCount=1  WarmupCount=5

| Method                  | Mean        | Error     | StdDev   | Ratio | RatioSD | Gen0     | Gen1     | Gen2     | Allocated | Alloc Ratio |
|------------------------ |------------:|----------:|---------:|------:|--------:|---------:|---------:|---------:|----------:|------------:|
| 'System.Drawing Resize' | 10,800.2 us | 394.51 us | 61.05 us |  1.00 |    0.00 |        - |        - |        - |     145 B |        1.00 |
| 'ImageFlow Resize'      |  7,577.5 us | 216.51 us | 33.51 us |  0.70 |    0.00 |  15.6250 |        - |        - |  116684 B |      804.72 |
| 'ImageSharp Resize'     |  2,553.8 us | 336.17 us | 87.30 us |  0.24 |    0.01 |        - |        - |        - |   14829 B |      102.27 |
| 'ImageMagick Resize'    | 44,196.7 us | 377.21 us | 58.37 us |  4.09 |    0.02 |        - |        - |        - |    5381 B |       37.11 |
| 'FreeImage Resize'      |  6,981.2 us | 298.37 us | 46.17 us |  0.65 |    0.01 | 500.0000 | 500.0000 | 500.0000 |     309 B |        2.13 |
| 'MagicScaler Resize'    |    697.8 us |  38.55 us | 10.01 us |  0.06 |    0.00 |        - |        - |        - |    1493 B |       10.30 |
| 'SkiaSharp Resize'      |  1,886.5 us |  86.54 us | 22.48 us |  0.17 |    0.00 |        - |        - |        - |     489 B |        3.37 |
| 'NetVips Resize'        | 12,906.8 us | 168.46 us | 26.07 us |  1.20 |    0.01 |        - |        - |        - |    3868 B |       26.68 |

Output quality seems poor. Color metadata is preserved but to my eye it's even more blurred than SkiasSharp and well below the standard of NetVips and ImageSharp and the gold standard of MagicScaler.

ImageFlow IMG_2325-ImageFlow SkiaSharp IMG_2325-SkiaSharpBitmap NetVips IMG_2325-NetVips ImageSharp IMG_2325-ImageSharp MagicScaler IMG_2325-MagicScaler

@MichaelSorensen If you give me push access to your fork, I can push the updates to your PR unless you want to make them yoursef?

JimBobSquarePants avatar Oct 03 '23 06:10 JimBobSquarePants

@JimBobSquarePants Thanks - that would be great. You should have access now. Let me know if that isn't the case.

MichaelSorensen avatar Oct 03 '23 07:10 MichaelSorensen

Done! πŸ˜€

JimBobSquarePants avatar Oct 03 '23 12:10 JimBobSquarePants

Thanks a lot! Have a good one :)

MichaelSorensen avatar Oct 03 '23 13:10 MichaelSorensen

Don’t think you meant to close this.

JimBobSquarePants avatar Oct 03 '23 19:10 JimBobSquarePants

You're absolutely true.. Sorry for that. Have a good one.

MichaelSorensen avatar Oct 03 '23 20:10 MichaelSorensen

Well, there, I merged it :D

bleroy avatar Oct 03 '23 20:10 bleroy