maforget / ComicRackCE

A Community Edition for the legendary Comic Book Manager ComicRack. ComicRack is back from the dead.
GNU General Public License v2.0
213 stars 20 forks source link

Using ImageScaler for resizing images #83

Open maforget opened 1 week ago

maforget commented 1 week ago

Just a test that uses ImageScaler for resizing images. Is the performance better? No more annoying crash due to AccessViolationException?

Are the Interpolation Setting correct?

FastAndUgly => NearestNeighbor
FastBilinear => Linear
FastBicubic => Cubic
BilinearHQ => Quadratic
GdiPlus => Hermite
GdiPlusHQ => Lanczos
github-actions[bot] commented 1 week ago

Build Successful! You can find a link to the downloadable artifact below.

Name Link
Commit 1e676bdfe6a8324f66f3561ae09a96c723f441c2
Logs https://github.com/maforget/ComicRackCE/actions/runs/9534701062
Download https://github.com/maforget/ComicRackCE/suites/24954685024/artifacts/1605865074
maforget commented 1 week ago

Some info how MagicScaler resizing relates to GDI Interpolation: https://photosauce.net/blog/post/image-scaling-with-gdi-part-4-examining-the-interpolationmode-values

Usually the usage of each interpolation in ComicRack are:

Here is the benchmark of ComicRack Resizer vs MagicScaler (when not specified Hybrid is Off, for better comparaison): Screenshot 2024-06-15 170717

So for now I changed some setting based on the blog page (the default when not speficied on the previous settings was FavorQuality):

FastAndUgly => NearestNeighbor, FavorSpeed
FastBilinear => Linear, FavorSpeed
FastBicubic => CatmullRom, FavorSpeed
BilinearHQ => Quadratic, FavorQuality
GdiPlus => Linear, FavorQuality
GdiPlusHQ => Cubic, Off

Some info about HybridMode: https://docs.photosauce.net/api/PhotoSauce.MagicScaler.HybridScaleMode.html#fields

maforget commented 1 week ago

After testing, Legacy is still way faster. Even considering the benchmark values. I believe is the multiple conversion from byte[] => Bitmap => byte[] => Bitmap are to blame.

I've started trying to implement a Custom PixelSource instead to pass to MagicScaler, but the current implementation gives corrupted images.