mirror of
https://github.com/Cykooz/fast_image_resize.git
synced 2026-10-08 01:11:09 +00:00
Added example of command line application "resizer".
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## [Unreleased] - ReleaseDate
|
||||
|
||||
- Added example of command line application "resizer".
|
||||
|
||||
## [0.9.7] - 2022-07-14
|
||||
|
||||
- Fixed resizing when the destination image has the same dimensions
|
||||
|
||||
Generated
+228
-46
@@ -31,6 +31,15 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.58"
|
||||
@@ -54,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69f2bd7ff6ed6414f4e5521bd509bae46454bbd513801767ced3f21a751ab4bc"
|
||||
dependencies = [
|
||||
"argh_shared",
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
@@ -66,6 +75,17 @@ version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47253b98986dafc7a3e1cf3259194f1f47ac61abb57a57f46ec09e48d004ecda"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
@@ -110,9 +130,9 @@ checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.10.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c53dfa917ec274df8ed3c572698f381a24eef2efba9492d797301b72b6db408a"
|
||||
checksum = "a5377c8865e74a160d21f29c2d40669f53286db6eab59b88540cbb12ffc8b835"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@@ -149,6 +169,55 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54635806b078b7925d6e36810b1755f2a4b5b4d57560432c1ecf60bcbe10602b"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap-verbosity-flag"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0636f9c040082f8e161555a305f8cec1a1c2828b3d981c812b8c39f4ac00c42c"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902"
|
||||
dependencies = [
|
||||
"heck 0.4.0",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cli-log"
|
||||
version = "2.0.0"
|
||||
@@ -187,9 +256,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845"
|
||||
checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-channel",
|
||||
@@ -201,9 +270,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c"
|
||||
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
@@ -211,9 +280,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
|
||||
checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-epoch",
|
||||
@@ -222,9 +291,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.9"
|
||||
version = "0.9.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d"
|
||||
checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
@@ -236,9 +305,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.5"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
|
||||
checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
@@ -246,9 +315,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.10"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
|
||||
checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -358,6 +427,19 @@ version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.4.2"
|
||||
@@ -392,7 +474,7 @@ version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c195cf4b2285d3c993eb887b4dc56b0d5728bbe1d0f9a99c0ac6bec2da3e4d85"
|
||||
dependencies = [
|
||||
"hashbrown 0.12.2",
|
||||
"hashbrown 0.12.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -412,9 +494,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.7.0"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
|
||||
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
@@ -437,9 +519,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "flume"
|
||||
version = "0.10.13"
|
||||
version = "0.10.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ceeb589a3157cac0ab8cc585feb749bd2cea5cb55a6ee802ad72d9fd38303da"
|
||||
checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@@ -545,9 +627,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.2"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
dependencies = [
|
||||
"ahash 0.7.6",
|
||||
]
|
||||
@@ -570,6 +652,12 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
@@ -579,6 +667,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.3"
|
||||
@@ -592,9 +686,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.2"
|
||||
version = "0.24.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28edd9d7bc256be2502e325ac0628bde30b7001b9b52e0abe31a1a9dc2701212"
|
||||
checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
@@ -602,7 +696,6 @@ dependencies = [
|
||||
"exr",
|
||||
"gif",
|
||||
"jpeg-decoder",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"png",
|
||||
@@ -610,6 +703,16 @@ dependencies = [
|
||||
"tiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown 0.12.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inflate"
|
||||
version = "0.4.5"
|
||||
@@ -801,9 +904,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.24.1"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9"
|
||||
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@@ -820,17 +923,6 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.1"
|
||||
@@ -877,6 +969,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
@@ -950,6 +1048,30 @@ dependencies = [
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.40"
|
||||
@@ -1003,9 +1125,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.13"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"
|
||||
checksum = "534cfe58d6a18cc17120fbf4635d53d14691c1fe4d951064df9bd326178d7d5a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
@@ -1021,12 +1143,29 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
version = "0.5.3"
|
||||
@@ -1046,6 +1185,19 @@ dependencies = [
|
||||
"rgb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "resizer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"clap-verbosity-flag",
|
||||
"env_logger",
|
||||
"fast_image_resize",
|
||||
"image",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rgb"
|
||||
version = "0.8.33"
|
||||
@@ -1090,18 +1242,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.139"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6"
|
||||
checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.139"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb"
|
||||
checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1164,6 +1316,12 @@ dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "svg"
|
||||
version = "0.8.2"
|
||||
@@ -1201,6 +1359,15 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termimad"
|
||||
version = "0.20.2"
|
||||
@@ -1223,6 +1390,12 @@ dependencies = [
|
||||
"image",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.31"
|
||||
@@ -1297,9 +1470,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
|
||||
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
@@ -1434,6 +1607,15 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
||||
+3
-3
@@ -1,6 +1,7 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"testing",
|
||||
"resizer",
|
||||
]
|
||||
|
||||
|
||||
@@ -17,7 +18,6 @@ repository = "https://github.com/cykooz/fast_image_resize"
|
||||
documentation = "https://docs.rs/crate/fast_image_resize"
|
||||
exclude = ["/data"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
num-traits = "0.2.15"
|
||||
@@ -26,7 +26,7 @@ thiserror = "1.0.31"
|
||||
|
||||
[dev-dependencies]
|
||||
glassbench = "0.3.3"
|
||||
image = "0.24.2"
|
||||
image = "0.24.3"
|
||||
resize = "0.7.3"
|
||||
rgb = "0.8.33"
|
||||
png = "0.17.5"
|
||||
@@ -89,10 +89,10 @@ opt-level = 3
|
||||
|
||||
|
||||
[profile.release]
|
||||
#debug = true
|
||||
lto = true
|
||||
opt-level = 3
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
|
||||
|
||||
[profile.test]
|
||||
|
||||
@@ -49,11 +49,11 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| image | 18.75 | 83.16 | 148.86 | 205.11 |
|
||||
| resize | - | 52.27 | 103.40 | 154.10 |
|
||||
| fir rust | 0.28 | 41.93 | 76.81 | 114.10 |
|
||||
| fir sse4.1 | 0.28 | 27.98 | 43.16 | 58.43 |
|
||||
| fir avx2 | 0.28 | 7.42 | 9.71 | 13.91 |
|
||||
| image | 19.01 | 84.06 | 148.84 | 205.25 |
|
||||
| resize | - | 52.21 | 104.32 | 154.11 |
|
||||
| fir rust | 0.28 | 41.75 | 76.85 | 113.11 |
|
||||
| fir sse4.1 | 0.28 | 28.16 | 43.00 | 59.62 |
|
||||
| fir avx2 | 0.28 | 7.41 | 9.61 | 13.84 |
|
||||
|
||||
### Resize RGBA8 image (U8x4) 4928x3279 => 852x567
|
||||
|
||||
@@ -68,12 +68,12 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| resize | - | 61.37 | 122.00 | 181.84 |
|
||||
| fir rust | 0.18 | 37.42 | 53.36 | 75.87 |
|
||||
| fir sse4.1 | 0.18 | 13.33 | 17.40 | 22.71 |
|
||||
| fir avx2 | 0.18 | 9.69 | 12.09 | 16.35 |
|
||||
| resize | - | 61.94 | 122.19 | 182.60 |
|
||||
| fir rust | 0.19 | 37.33 | 53.29 | 76.49 |
|
||||
| fir sse4.1 | 0.19 | 13.14 | 17.25 | 22.59 |
|
||||
| fir avx2 | 0.19 | 9.59 | 12.09 | 16.18 |
|
||||
|
||||
### Resize L8 (luma) image (U8) 4928x3279 => 852x567
|
||||
### Resize L8 image (U8) 4928x3279 => 852x567
|
||||
|
||||
Pipeline:
|
||||
|
||||
@@ -85,11 +85,11 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| image | 15.48 | 46.20 | 73.56 | 101.74 |
|
||||
| resize | - | 17.29 | 35.60 | 61.27 |
|
||||
| fir rust | 0.16 | 13.79 | 15.31 | 22.76 |
|
||||
| fir sse4.1 | 0.16 | 12.01 | 12.12 | 18.10 |
|
||||
| fir avx2 | 0.16 | 6.29 | 4.81 | 7.71 |
|
||||
| image | 15.60 | 45.30 | 72.95 | 102.13 |
|
||||
| resize | - | 17.29 | 35.45 | 61.14 |
|
||||
| fir rust | 0.15 | 13.91 | 15.37 | 22.86 |
|
||||
| fir sse4.1 | 0.15 | 12.16 | 12.16 | 18.19 |
|
||||
| fir avx2 | 0.15 | 6.33 | 4.66 | 7.69 |
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
+39
-39
@@ -5,13 +5,13 @@ Environment:
|
||||
- CPU: AMD Ryzen 9 5950X
|
||||
- RAM: DDR4 3800 MHz
|
||||
- Ubuntu 22.04 (linux 5.15.0)
|
||||
- Rust 1.62.0
|
||||
- fast_image_resize = "0.9.7"
|
||||
- Rust 1.62.1
|
||||
- fast_image_resize = "1.0.0"
|
||||
- glassbench = "0.3.3"
|
||||
|
||||
Other Rust libraries used to compare of resizing speed:
|
||||
|
||||
- image = "0.24.2" (<https://crates.io/crates/image>)
|
||||
- image = "0.24.3" (<https://crates.io/crates/image>)
|
||||
- resize = "0.7.3" (<https://crates.io/crates/resize>)
|
||||
|
||||
Resize algorithms:
|
||||
@@ -32,11 +32,11 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| image | 18.75 | 83.16 | 148.86 | 205.11 |
|
||||
| resize | - | 52.27 | 103.40 | 154.10 |
|
||||
| fir rust | 0.28 | 41.93 | 76.81 | 114.10 |
|
||||
| fir sse4.1 | 0.28 | 27.98 | 43.16 | 58.43 |
|
||||
| fir avx2 | 0.28 | 7.42 | 9.71 | 13.91 |
|
||||
| image | 19.01 | 84.06 | 148.84 | 205.25 |
|
||||
| resize | - | 52.21 | 104.32 | 154.11 |
|
||||
| fir rust | 0.28 | 41.75 | 76.85 | 113.11 |
|
||||
| fir sse4.1 | 0.28 | 28.16 | 43.00 | 59.62 |
|
||||
| fir avx2 | 0.28 | 7.41 | 9.61 | 13.84 |
|
||||
|
||||
### Resize RGBA8 image (U8x4) 4928x3279 => 852x567
|
||||
|
||||
@@ -51,12 +51,12 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| resize | - | 61.37 | 122.00 | 181.84 |
|
||||
| fir rust | 0.18 | 37.42 | 53.36 | 75.87 |
|
||||
| fir sse4.1 | 0.18 | 13.33 | 17.40 | 22.71 |
|
||||
| fir avx2 | 0.18 | 9.69 | 12.09 | 16.35 |
|
||||
| resize | - | 61.94 | 122.19 | 182.60 |
|
||||
| fir rust | 0.19 | 37.33 | 53.29 | 76.49 |
|
||||
| fir sse4.1 | 0.19 | 13.14 | 17.25 | 22.59 |
|
||||
| fir avx2 | 0.19 | 9.59 | 12.09 | 16.18 |
|
||||
|
||||
### Resize L8 (luma) image (U8) 4928x3279 => 852x567
|
||||
### Resize L8 image (U8) 4928x3279 => 852x567
|
||||
|
||||
Pipeline:
|
||||
|
||||
@@ -68,13 +68,13 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| image | 15.48 | 46.20 | 73.56 | 101.74 |
|
||||
| resize | - | 17.29 | 35.60 | 61.27 |
|
||||
| fir rust | 0.16 | 13.79 | 15.31 | 22.76 |
|
||||
| fir sse4.1 | 0.16 | 12.01 | 12.12 | 18.10 |
|
||||
| fir avx2 | 0.16 | 6.29 | 4.81 | 7.71 |
|
||||
| image | 15.60 | 45.30 | 72.95 | 102.13 |
|
||||
| resize | - | 17.29 | 35.45 | 61.14 |
|
||||
| fir rust | 0.15 | 13.91 | 15.37 | 22.86 |
|
||||
| fir sse4.1 | 0.15 | 12.16 | 12.16 | 18.19 |
|
||||
| fir avx2 | 0.15 | 6.33 | 4.66 | 7.69 |
|
||||
|
||||
### Resize LA8 (luma with alpha channel) image (U8x2) 4928x3279 => 852x567
|
||||
### Resize LA8 image (U8x2) 4928x3279 => 852x567
|
||||
|
||||
Pipeline:
|
||||
|
||||
@@ -89,9 +89,9 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| fir rust | 0.17 | 25.97 | 31.30 | 43.20 |
|
||||
| fir sse4.1 | 0.17 | 12.73 | 14.69 | 18.16 |
|
||||
| fir avx2 | 0.17 | 11.24 | 12.51 | 15.45 |
|
||||
| fir rust | 0.17 | 25.48 | 31.83 | 43.72 |
|
||||
| fir sse4.1 | 0.17 | 12.81 | 14.69 | 18.12 |
|
||||
| fir avx2 | 0.17 | 11.27 | 12.45 | 15.48 |
|
||||
|
||||
### Resize RGB16 image (U16x3) 4928x3279 => 852x567
|
||||
|
||||
@@ -105,11 +105,11 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| image | 18.34 | 75.56 | 136.94 | 186.09 |
|
||||
| resize | - | 55.09 | 107.12 | 158.71 |
|
||||
| fir rust | 0.33 | 43.65 | 79.55 | 117.51 |
|
||||
| fir sse4.1 | 0.33 | 24.39 | 39.47 | 55.81 |
|
||||
| fir avx2 | 0.33 | 20.79 | 30.79 | 36.76 |
|
||||
| image | 18.28 | 75.10 | 137.04 | 189.89 |
|
||||
| resize | - | 54.71 | 106.93 | 158.29 |
|
||||
| fir rust | 0.33 | 43.65 | 79.56 | 117.31 |
|
||||
| fir sse4.1 | 0.33 | 24.34 | 39.55 | 55.89 |
|
||||
| fir avx2 | 0.33 | 20.67 | 30.81 | 36.98 |
|
||||
|
||||
### Resize RGBA16 image (U16x4) 4928x3279 => 852x567
|
||||
|
||||
@@ -124,10 +124,10 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| resize | - | 63.90 | 127.59 | 191.40 |
|
||||
| fir rust | 0.37 | 87.77 | 125.78 | 165.53 |
|
||||
| fir sse4.1 | 0.37 | 42.54 | 63.71 | 85.59 |
|
||||
| fir avx2 | 0.37 | 23.43 | 34.04 | 45.37 |
|
||||
| resize | - | 63.93 | 127.61 | 191.17 |
|
||||
| fir rust | 0.40 | 89.83 | 125.96 | 167.05 |
|
||||
| fir sse4.1 | 0.40 | 42.24 | 63.53 | 85.53 |
|
||||
| fir avx2 | 0.40 | 23.53 | 34.14 | 45.43 |
|
||||
|
||||
### Resize L16 image (U16) 4928x3279 => 852x567
|
||||
|
||||
@@ -141,11 +141,11 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| image | 15.70 | 45.79 | 73.63 | 103.38 |
|
||||
| resize | - | 15.52 | 32.13 | 57.22 |
|
||||
| fir rust | 0.17 | 18.51 | 27.75 | 38.42 |
|
||||
| fir sse4.1 | 0.17 | 7.77 | 13.21 | 19.16 |
|
||||
| fir avx2 | 0.17 | 7.07 | 9.54 | 14.81 |
|
||||
| image | 15.53 | 45.82 | 73.87 | 103.21 |
|
||||
| resize | - | 15.44 | 31.92 | 57.15 |
|
||||
| fir rust | 0.18 | 18.86 | 27.52 | 38.34 |
|
||||
| fir sse4.1 | 0.18 | 7.93 | 13.28 | 19.24 |
|
||||
| fir avx2 | 0.18 | 7.16 | 9.50 | 14.54 |
|
||||
|
||||
### Resize LA16 (luma with alpha channel) image (U16x2) 4928x3279 => 852x567
|
||||
|
||||
@@ -162,6 +162,6 @@ Pipeline:
|
||||
|
||||
| | Nearest | Bilinear | CatmullRom | Lanczos3 |
|
||||
|------------|:-------:|:--------:|:----------:|:--------:|
|
||||
| fir rust | 0.19 | 33.85 | 53.43 | 72.17 |
|
||||
| fir sse4.1 | 0.19 | 21.92 | 34.05 | 46.44 |
|
||||
| fir avx2 | 0.19 | 15.16 | 21.93 | 28.98 |
|
||||
| fir rust | 0.19 | 33.54 | 52.84 | 71.97 |
|
||||
| fir sse4.1 | 0.19 | 21.87 | 34.08 | 46.61 |
|
||||
| fir avx2 | 0.19 | 15.19 | 21.93 | 29.07 |
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "resizer"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
fast_image_resize = {path=".."}
|
||||
image = "0.24.2"
|
||||
clap = { version = "3.2.14", features = ["derive"] }
|
||||
log = "0.4.17"
|
||||
env_logger = "0.9.0"
|
||||
anyhow = "1.0.58"
|
||||
clap-verbosity-flag = "1.0.1"
|
||||
@@ -0,0 +1,227 @@
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt::Debug;
|
||||
use std::num::NonZeroU32;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use clap::Parser;
|
||||
use image::io::Reader as ImageReader;
|
||||
use image::ColorType;
|
||||
use log::debug;
|
||||
|
||||
use fast_image_resize as fr;
|
||||
|
||||
mod structs;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(author = "Kirill K.")]
|
||||
#[clap(version, about, long_about = None)]
|
||||
struct Cli {
|
||||
/// Path to source image file
|
||||
#[clap(value_parser)]
|
||||
source_path: PathBuf,
|
||||
|
||||
/// Path to result image file
|
||||
#[clap(value_parser)]
|
||||
destination_path: Option<PathBuf>,
|
||||
|
||||
/// Width of result image
|
||||
#[clap(short, long, value_parser)]
|
||||
width: Option<NonZeroU32>,
|
||||
|
||||
/// Height of result image
|
||||
#[clap(short, long, value_parser)]
|
||||
height: Option<NonZeroU32>,
|
||||
|
||||
/// Overwrite destination file
|
||||
#[clap(short, long, action)]
|
||||
overwrite: bool,
|
||||
|
||||
/// Algorithm used to resize image
|
||||
#[clap(short, long, value_enum, default_value_t = structs::Algorithm::Convolution)]
|
||||
algorithm: structs::Algorithm,
|
||||
|
||||
/// Type of filter used with the "convolution" resizing algorithm
|
||||
#[clap(short, long, value_enum, default_value_t = structs::FilterType::Lanczos3)]
|
||||
filter: structs::FilterType,
|
||||
|
||||
#[clap(flatten)]
|
||||
verbose: clap_verbosity_flag::Verbosity,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let cli: Cli = Cli::parse();
|
||||
env_logger::Builder::new()
|
||||
.filter_level(cli.verbose.log_level_filter())
|
||||
.init();
|
||||
resize(&cli)
|
||||
}
|
||||
|
||||
fn resize(cli: &Cli) -> Result<()> {
|
||||
let (mut src_image, color_type) = open_source_image(&cli.source_path)?;
|
||||
let mut dst_image = create_destination_image(cli, &src_image);
|
||||
|
||||
let mul_div = fr::MulDiv::default();
|
||||
let algorithm = get_resizing_algorithm(cli);
|
||||
let mut resizer = fr::Resizer::new(algorithm);
|
||||
|
||||
if color_type.has_alpha() {
|
||||
debug!("Multiply color channels of the source image by alpha channel");
|
||||
mul_div
|
||||
.multiply_alpha_inplace(&mut src_image.view_mut())
|
||||
.with_context(|| "Failed to multiply color channels by alpha")?;
|
||||
}
|
||||
|
||||
debug!(
|
||||
"Resize the source image into {}x{}",
|
||||
dst_image.width(),
|
||||
dst_image.height()
|
||||
);
|
||||
resizer
|
||||
.resize(&src_image.view(), &mut dst_image.view_mut())
|
||||
.with_context(|| "Failed to resize image")?;
|
||||
|
||||
if color_type.has_alpha() {
|
||||
debug!("Divide color channels of the result image by alpha channel");
|
||||
mul_div
|
||||
.divide_alpha_inplace(&mut dst_image.view_mut())
|
||||
.with_context(|| "Failed to divide color channels by alpha")?;
|
||||
}
|
||||
|
||||
save_result(cli, &dst_image, color_type)
|
||||
}
|
||||
|
||||
fn open_source_image<P>(source_path: P) -> Result<(fr::Image<'static>, ColorType)>
|
||||
where
|
||||
P: AsRef<Path> + Debug,
|
||||
{
|
||||
debug!("Opening the source image {:?}", source_path);
|
||||
let image = ImageReader::open(&source_path)
|
||||
.with_context(|| format!("Failed to read source file from {:?}", source_path))?
|
||||
.decode()
|
||||
.with_context(|| "Failed to decode source image")?;
|
||||
|
||||
let src_width = NonZeroU32::new(image.width())
|
||||
.with_context(|| "Failed to get width of the source image")?;
|
||||
let src_height = NonZeroU32::new(image.height())
|
||||
.with_context(|| "Failed to get height of the source image")?;
|
||||
|
||||
let color_type = image.color();
|
||||
let (src_buffer, pixel_type) = match color_type {
|
||||
ColorType::L8 => (image.to_luma8().into_raw(), fr::PixelType::U8),
|
||||
ColorType::La8 => (image.to_luma_alpha8().into_raw(), fr::PixelType::U8x2),
|
||||
ColorType::Rgb8 => (image.to_rgb8().into_raw(), fr::PixelType::U8x3),
|
||||
ColorType::Rgba8 => (image.to_rgba8().into_raw(), fr::PixelType::U8x4),
|
||||
ColorType::L16 => (
|
||||
image
|
||||
.to_luma16()
|
||||
.as_raw()
|
||||
.iter()
|
||||
.flat_map(|&c| c.to_le_bytes())
|
||||
.collect(),
|
||||
fr::PixelType::U16,
|
||||
),
|
||||
ColorType::La16 => (
|
||||
image
|
||||
.to_luma_alpha16()
|
||||
.as_raw()
|
||||
.iter()
|
||||
.flat_map(|&c| c.to_le_bytes())
|
||||
.collect(),
|
||||
fr::PixelType::U16x2,
|
||||
),
|
||||
ColorType::Rgb16 => (
|
||||
image
|
||||
.to_rgb16()
|
||||
.as_raw()
|
||||
.iter()
|
||||
.flat_map(|&c| c.to_le_bytes())
|
||||
.collect(),
|
||||
fr::PixelType::U16x3,
|
||||
),
|
||||
ColorType::Rgba16 => (
|
||||
image
|
||||
.to_rgba16()
|
||||
.as_raw()
|
||||
.iter()
|
||||
.flat_map(|&c| c.to_le_bytes())
|
||||
.collect(),
|
||||
fr::PixelType::U16x4,
|
||||
),
|
||||
_ => {
|
||||
return Err(anyhow!(
|
||||
"Unsupported pixel's format of source image: {:?}",
|
||||
color_type
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
Ok((
|
||||
fr::Image::from_vec_u8(src_width, src_height, src_buffer, pixel_type)
|
||||
.with_context(|| "Failed to create source image pixels container")?,
|
||||
color_type,
|
||||
))
|
||||
}
|
||||
|
||||
fn create_destination_image(cli: &Cli, src_image: &fr::Image) -> fr::Image<'static> {
|
||||
let aspect_ratio = src_image.width().get() as f32 / src_image.height().get() as f32;
|
||||
|
||||
let (dst_width, dst_height) = match (cli.width, cli.height) {
|
||||
(None, None) => (src_image.width(), src_image.height()),
|
||||
(Some(width), None) => (
|
||||
width,
|
||||
get_non_zero_u32((width.get() as f32 / aspect_ratio).round() as u32),
|
||||
),
|
||||
(None, Some(height)) => (
|
||||
get_non_zero_u32((height.get() as f32 * aspect_ratio).round() as u32),
|
||||
height,
|
||||
),
|
||||
(Some(width), Some(height)) => (width, height),
|
||||
};
|
||||
|
||||
fr::Image::new(dst_width, dst_height, src_image.pixel_type())
|
||||
}
|
||||
|
||||
fn get_non_zero_u32(v: u32) -> NonZeroU32 {
|
||||
NonZeroU32::new(v).unwrap_or(NonZeroU32::new(1).unwrap())
|
||||
}
|
||||
|
||||
fn get_resizing_algorithm(cli: &Cli) -> fr::ResizeAlg {
|
||||
let filter_type: fr::FilterType = cli.filter.into();
|
||||
match cli.algorithm {
|
||||
structs::Algorithm::Nearest => fr::ResizeAlg::Nearest,
|
||||
structs::Algorithm::Convolution => fr::ResizeAlg::Convolution(filter_type),
|
||||
structs::Algorithm::SuperSampling => fr::ResizeAlg::SuperSampling(filter_type, 2),
|
||||
}
|
||||
}
|
||||
|
||||
fn save_result(cli: &Cli, image: &fr::Image, color_type: ColorType) -> Result<()> {
|
||||
let result_path = if let Some(path) = cli.destination_path.clone() {
|
||||
path
|
||||
} else {
|
||||
let mut path = PathBuf::from("./");
|
||||
let ext = cli
|
||||
.source_path
|
||||
.extension()
|
||||
.unwrap_or_else(|| OsStr::new("png"));
|
||||
path.push("result");
|
||||
path.set_extension(ext);
|
||||
path
|
||||
};
|
||||
if result_path.exists() && !cli.overwrite {
|
||||
return Err(anyhow!(
|
||||
"Destination path {:?} already exists.",
|
||||
result_path
|
||||
));
|
||||
};
|
||||
debug!("Save the result image into the file {:?}", result_path);
|
||||
image::save_buffer(
|
||||
result_path,
|
||||
image.buffer(),
|
||||
image.width().get(),
|
||||
image.height().get(),
|
||||
color_type,
|
||||
)
|
||||
.with_context(|| "Failed to save the result image")?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
use fast_image_resize as fr;
|
||||
|
||||
#[derive(Copy, Clone, Debug, clap::ValueEnum)]
|
||||
pub enum Algorithm {
|
||||
Nearest,
|
||||
Convolution,
|
||||
SuperSampling,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, clap::ValueEnum)]
|
||||
pub enum FilterType {
|
||||
/// Each pixel of source image contributes to one pixel of the
|
||||
/// destination image with identical weights. For upscaling is equivalent
|
||||
/// of `Nearest` resize algorithm.
|
||||
Box,
|
||||
/// Bilinear filter calculate the output pixel value using linear
|
||||
/// interpolation on all pixels that may contribute to the output value.
|
||||
Bilinear,
|
||||
/// Hamming filter has the same performance as `Bilinear` filter while
|
||||
/// providing the image downscaling quality comparable to bicubic
|
||||
/// (`CatmulRom` or `Mitchell`). Produces a sharper image than `Bilinear`,
|
||||
/// doesn't have dislocations on local level like with `Box`.
|
||||
/// The filter don’t show good quality for the image upscaling.
|
||||
Hamming,
|
||||
/// Catmull-Rom bicubic filter calculate the output pixel value using
|
||||
/// cubic interpolation on all pixels that may contribute to the output
|
||||
/// value.
|
||||
CatmullRom,
|
||||
/// Mitchell–Netravali bicubic filter calculate the output pixel value
|
||||
/// using cubic interpolation on all pixels that may contribute to the
|
||||
/// output value.
|
||||
Mitchell,
|
||||
/// Lanczos3 filter calculate the output pixel value using a high-quality
|
||||
/// Lanczos filter (a truncated sinc) on all pixels that may contribute
|
||||
/// to the output value.
|
||||
Lanczos3,
|
||||
}
|
||||
|
||||
impl From<FilterType> for fr::FilterType {
|
||||
fn from(filter_type: FilterType) -> Self {
|
||||
match filter_type {
|
||||
FilterType::Box => fr::FilterType::Box,
|
||||
FilterType::Bilinear => fr::FilterType::Bilinear,
|
||||
FilterType::Hamming => fr::FilterType::Hamming,
|
||||
FilterType::CatmullRom => fr::FilterType::CatmullRom,
|
||||
FilterType::Mitchell => fr::FilterType::Mitchell,
|
||||
FilterType::Lanczos3 => fr::FilterType::Lanczos3,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ const fn get_clip_table() -> [u8; 1280] {
|
||||
}
|
||||
|
||||
// Handles values form -640 to 639.
|
||||
const CLIP8_LOOKUPS: [u8; 1280] = get_clip_table();
|
||||
static CLIP8_LOOKUPS: [u8; 1280] = get_clip_table();
|
||||
|
||||
// 8 bits for result. Filter can have negative areas.
|
||||
// In one cases the sum of the coefficients will be negative,
|
||||
|
||||
Reference in New Issue
Block a user