From 50b9b3cf792453251bef5a5db5e719d597ec13a0 Mon Sep 17 00:00:00 2001 From: LinkChou Date: Sun, 31 Mar 2024 01:29:34 +0800 Subject: [PATCH 1/9] docs: correct typos and improve help info --- README.md | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index a231358..2885abe 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ You can download latest release from the [releases](https://github.com/SalOne22/ If you're a Rust programmer, rimage can be installed with `cargo`. -```sh +```powershell cargo install rimage ``` Alternatively, one can use [cargo binstall](https://github.com/cargo-bins/cargo-binstall) to install a rimage binary directly from GitHub: -```sh +```powershell cargo binstall rimage ``` @@ -66,20 +66,20 @@ Options: To optimize images with great defaults, you can simply call `rimage `. For example: -```sh +```powershell rimage mozjpeg ./image.jpg ``` -By default rimage will place output images right in place of precious images, resulting in overwrite if input and output has the same format. To change this behavior you can use this options: +By default, rimage will place the output image directly in the same folder as the input image, which can cause OVERWRITING if the input and output images have the same file extension name. To change this behavior, you can use the following options: -```sh -# will place output images in `./output` directory, images may be overwritten if has the same name +```powershell +# Will place output images in `./output` directory, images may be overwritten if has the same name rimage mozjpeg -d ./output ./image.jpg -# will rename all input files before processing with `@backup` suffix +# Will rename all input files before processing with `@backup` suffix rimage mozjpeg --backup ./image.jpg -# will place output images in ./output directory preserving folder structure +# Will place output images in ./output directory preserving folder structure rimage mozjpeg -d ./output -r ./inner/image.jpg ./image.jpg ``` @@ -87,14 +87,14 @@ rimage mozjpeg -d ./output -r ./inner/image.jpg ./image.jpg Rimage has pipeline preprocessing options. Simple usage: -```sh +```powershell # will resize image to specified dimensions rimage mozjpeg --resize 500x200 ./image.jpg ``` If you want to run preprocessing pipeline in specific order, you can do this: -```sh +```powershell # will quantize image with 80% quality, after run resize to 64x64 pixels using the Nearest filter. rimage mozjpeg --quantization 80 --resize 64x64 --filter nearest ./image.jpg @@ -121,7 +121,7 @@ Options: --qtable Use a specific quantization table. [default: NRobidoux] [possible values: AhumadaWatsonPeterson, AnnexK, Flat, KleinSilversteinCarney, MSSSIM, NRobidoux, PSNRHVS, PetersonAhumadaWatson, WatsonTaylorBorthwick] ``` -For more info use `rimage help ` +For more info use `rimage help `, e.g. `rimage help moz` For library usage check [Docs.rs](https://docs.rs/rimage/latest/rimage/) @@ -151,20 +151,26 @@ For library usage check [Docs.rs](https://docs.rs/rimage/latest/rimage/) - **Dir path end with `\` may cause rimage crashes** due to a cmd bug [#72653](https://github.com/rust-lang/rust/issues/72653). +> **Tip** +> We tremendously suggest to use double backslashes (`\\`) and place parameters with folder paths at the end of the command to avoid any accident. + ### Example: This will crash: -```sh +```powershell rimage png "D:\example.jpg" -d "D:\desktop\" -s "suffix" ``` -This will work as expected: +These will work as expected: -```sh -rimage png "D:\example.jpg" -d "D:\desktop" -s "suf test" # without trailing backslash +```powershell +rimage avif "D:\\example.jpg" -s "suffix" -d "D:\\desktop" # Highly Recommended +rimage moz "D:\\symble-^&-example.jpg" -s "suffix" -d "D:\\desktop\" # Recommended -rimage png "D:\example.jpg" -s "suffix" -d "D:\desktop\" # backslash at the end +rimage jxl "D:\space example.jpg" -d "D:\desktop" -b # Acceptable (Without trailing backslash) +rimage png "D:\β€œcjk中文”-example.jpg" --threads 4 -d "D:\desktop\" # Acceptable (Backslash at the end) +rimage webp "D:\emojy-πŸ˜„-example.jpg" -d ./desktop # Acceptable (Relative path) ``` ## Contributing From 662dfc187dfed25e23a4fc2491549d3a8083823a Mon Sep 17 00:00:00 2001 From: LinkChou Date: Sun, 31 Mar 2024 01:47:29 +0800 Subject: [PATCH 2/9] corrcet some --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2885abe..241754a 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ To optimize images with great defaults, you can simply call `rimage `. rimage mozjpeg ./image.jpg ``` -By default, rimage will place the output image directly in the same folder as the input image, which can cause OVERWRITING if the input and output images have the same file extension name. To change this behavior, you can use the following options: +By default, rimage will place output images directly in the same folder of each input image, which may cause OVERWRITING if the input and output images have the same file extension name. To change this behavior, you can use the following options: ```powershell # Will place output images in `./output` directory, images may be overwritten if has the same name From 67cceb1135f075d12de34ec67b404ff06dae7c0a Mon Sep 17 00:00:00 2001 From: LinkChou Date: Sun, 31 Mar 2024 01:52:01 +0800 Subject: [PATCH 3/9] correcnt typos --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 241754a..8cf89dd 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ To optimize images with great defaults, you can simply call `rimage `. rimage mozjpeg ./image.jpg ``` -By default, rimage will place output images directly in the same folder of each input image, which may cause OVERWRITING if the input and output images have the same file extension name. To change this behavior, you can use the following options: +By default, rimage will place output images directly in the same folder of each input image, which may cause OVERWRITING if the input and output image has the same file extension name. To change this behavior, you can use the following options: ```powershell # Will place output images in `./output` directory, images may be overwritten if has the same name From b3ef1eb80c3e0f45fdb80cb58b85d5a6eec43293 Mon Sep 17 00:00:00 2001 From: LinkChou Date: Sun, 31 Mar 2024 02:36:03 +0800 Subject: [PATCH 4/9] add detailed examples and move -d option to the end --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++------ src/cli/common.rs | 14 +++++++------- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8cf89dd..409bd9f 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Options: -V, --version Print version ``` -### Basic optimization suitable for web +### Basic optimization suitable for file transfer on web To optimize images with great defaults, you can simply call `rimage `. For example: @@ -106,7 +106,9 @@ Note that some preprocessing option are order independent. For example filter op ### Advanced options -If you want customize optimization you can provide additional options to encoders. For mozjpeg this options are valid: +If you want customize optimization you can provide additional options to encoders. + +For mozjpeg this options are valid: ``` Options: @@ -147,6 +149,38 @@ For library usage check [Docs.rs](https://docs.rs/rimage/latest/rimage/) - Quantization - Alpha premultiply +### Detailed Examples + +#### png -> jpg & quality -> 90 & backup + +| Image Path | Quality | Out Format | Out Dir | Backup | +| ------------------------------- | ------- | ---------- | ------------------------- | ------ | +| "D:\\Desktop\\input [text].png" | 90 | jpg | "D:\\Desktop\\OutputTest" | True | + +```powershell +rimage moz "D:\\Desktop\\input [text].png" -q 90 -d "D:\\Desktop\\OutputTest" -b +``` + +#### avif -> png & suffix & recursive & quantization & dithering + +| Image Path | Out Format | Suffix | Recursive | Quantization | Dithering | +| ------------------------------ | ---------- | ------ | --------- | ------------ | --------- | +| "C:\\δΈ­ &ζ–‡\\γ‚½γƒ•γƒˆγ‚¦γ‚§γ‚’.AVIF" | avif | \_문자 | Input dir | 95 | 85 | + +```powershell +rimage oxi "C:\\δΈ­ &ζ–‡\\γ‚½γƒ•γƒˆγ‚¦γ‚§γ‚’.AVIF" -s "_문자" -r --quantization 95 --dithering 85 -d "C:\\δΈ­ ζ–‡" +``` + +#### png -> webp & quality -> lossless & resize & filter + +| Image Path | Quality | Out Format | Out Dir | Width | Height |Filter| +| -------------- | -------- | ---------- | ------------------- | ----- | ------ |---| +| "C:\\test.png" | Lossless | png | "C:\\Desktop\\Test" | 200 | Auto |Bilinear| + +```powershell +rimage webp "C:\\test.png" --lossless --resize 200x_ --filter bilinear -d "C:\\Desktop\\Test" +``` + ## Known bugs - **Dir path end with `\` may cause rimage crashes** due to a cmd bug [#72653](https://github.com/rust-lang/rust/issues/72653). @@ -166,11 +200,11 @@ These will work as expected: ```powershell rimage avif "D:\\example.jpg" -s "suffix" -d "D:\\desktop" # Highly Recommended -rimage moz "D:\\symble-^&-example.jpg" -s "suffix" -d "D:\\desktop\" # Recommended +rimage moz "D:\\example.jpg" -s "suffix" -d "D:\\desktop\" # Recommended -rimage jxl "D:\space example.jpg" -d "D:\desktop" -b # Acceptable (Without trailing backslash) -rimage png "D:\β€œcjk中文”-example.jpg" --threads 4 -d "D:\desktop\" # Acceptable (Backslash at the end) -rimage webp "D:\emojy-πŸ˜„-example.jpg" -d ./desktop # Acceptable (Relative path) +rimage jxl "D:\example.jpg" -d "D:\desktop" -b # Acceptable (Without trailing backslash) +rimage png "D:\example.jpg" --threads 4 -d "D:\desktop\" # Acceptable (Backslash at the end) +rimage webp "D:\example.jpg" -d ./desktop # Acceptable (Relative path) ``` ## Contributing diff --git a/src/cli/common.rs b/src/cli/common.rs index edb3ae1..7b6d4a3 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -16,13 +16,6 @@ impl CommonArgs for Command { If the file path contains spaces, enclose the path with double quotation marks on both sides."#}) .value_parser(value_parser!(PathBuf)), ) - .arg( - arg!(-d --directory "The directory to write output file(s) to.") - .long_help(indoc! {r#"The directory to write output file(s) to. - - Output files will be written without preserving the folder structure unless the --recursive flag is used."#}) - .value_parser(value_parser!(PathBuf)), - ) .arg( arg!(-r --recursive "Preserves the folder structure when writing output file(s).") .long_help(indoc! {r#"Preserves the folder structure when writing output file(s). @@ -51,6 +44,13 @@ impl CommonArgs for Command { By default, the number of available threads is utilized."#}) .value_parser(value_parser!(u8).range(1..=threads::num_threads() as i64)), ) + .arg( + arg!(-d --directory "The directory to write output file(s) to.") + .long_help(indoc! {r#"The directory to write output file(s) to. + + Output files will be written without preserving the folder structure unless the --recursive flag is used."#}) + .value_parser(value_parser!(PathBuf)), + ) .preprocessors() } } From 1f692261b5bba587dce7789f35d4eaf243310f69 Mon Sep 17 00:00:00 2001 From: LinkChou Date: Sun, 31 Mar 2024 12:42:02 +0800 Subject: [PATCH 5/9] docs: change description of Preprocessing --- README.md | 65 +++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 409bd9f..1da1213 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ A powerful Rust image optimization CLI tool inspired by [squoosh!](https://squoo - Rimage provides several image optimization operation - Resize - uses `fast_image_resize` crate that has incredible performance - Quantization - allowing to reduce image palette +- CJK and Punctuation marks support: + - Rimage supports full CJK (Chinese, Japanese and Korean) characters input and output + - Rimage allows special punctuation characters such as `|`, ` `, `&`, `$`, etc. to be included in file names ## Installation @@ -88,17 +91,27 @@ rimage mozjpeg -d ./output -r ./inner/image.jpg ./image.jpg Rimage has pipeline preprocessing options. Simple usage: ```powershell -# will resize image to specified dimensions -rimage mozjpeg --resize 500x200 ./image.jpg +# Will resize image to specified dimensions +rimage mozjpeg --resize "500x200" ./image.jpg + +# Will zoom the image to the specified length (or width), and if another value is not specified, rimmage will automatically scale proportionally +rimage mozjpeg --resize "_x600" ./image.jpg + + +# Will resize the image by multiplier +rimage mozjpeg --resize "@0.9" ./image.jpg + +# Will resize the image size by percentage +rimage mozjpeg --resize "175%" ./image.jpg ``` If you want to run preprocessing pipeline in specific order, you can do this: ```powershell -# will quantize image with 80% quality, after run resize to 64x64 pixels using the Nearest filter. +# Will quantize image with 80% quality, after run resize to 64x64 pixels using the Nearest filter. rimage mozjpeg --quantization 80 --resize 64x64 --filter nearest ./image.jpg -# will resize image to 64x64 pixels using the Nearest filter, and after run quantization with 80% quality. +# Will resize image to 64x64 pixels using the Nearest filter, and after run quantization with 80% quality. rimage mozjpeg --resize 64x64 --filter nearest --quantization 80 ./image.jpg ``` @@ -151,35 +164,11 @@ For library usage check [Docs.rs](https://docs.rs/rimage/latest/rimage/) ### Detailed Examples -#### png -> jpg & quality -> 90 & backup - -| Image Path | Quality | Out Format | Out Dir | Backup | -| ------------------------------- | ------- | ---------- | ------------------------- | ------ | -| "D:\\Desktop\\input [text].png" | 90 | jpg | "D:\\Desktop\\OutputTest" | True | - -```powershell -rimage moz "D:\\Desktop\\input [text].png" -q 90 -d "D:\\Desktop\\OutputTest" -b -``` - -#### avif -> png & suffix & recursive & quantization & dithering +| Image Path | Out Format | Quality | Out Dir | Backup | Suffix | Recursive | Threads | | | Command | +| :----------------- | :--------: | :-----: | :----------- | :----: | :----------: | :-------: | :-----: | :---: | :------------------------------------------------------------------- | +| `C:\\example.png` | jpg | 90 | `D:\\Output` | True | False | True | Default | | | `rimage moz "C:\\example.png" -q 90 -r -d "D:\\Output" -b` | +| `C:\\example.AVIF` | png | Default | `D:\\Output` | False | `_add_suf` | False | True | | | `rimage oxi "C:\\example.AVIF" -s "_add_suf" -t 3 -d "D:\\Output"` | -| Image Path | Out Format | Suffix | Recursive | Quantization | Dithering | -| ------------------------------ | ---------- | ------ | --------- | ------------ | --------- | -| "C:\\δΈ­ &ζ–‡\\γ‚½γƒ•γƒˆγ‚¦γ‚§γ‚’.AVIF" | avif | \_문자 | Input dir | 95 | 85 | - -```powershell -rimage oxi "C:\\δΈ­ &ζ–‡\\γ‚½γƒ•γƒˆγ‚¦γ‚§γ‚’.AVIF" -s "_문자" -r --quantization 95 --dithering 85 -d "C:\\δΈ­ ζ–‡" -``` - -#### png -> webp & quality -> lossless & resize & filter - -| Image Path | Quality | Out Format | Out Dir | Width | Height |Filter| -| -------------- | -------- | ---------- | ------------------- | ----- | ------ |---| -| "C:\\test.png" | Lossless | png | "C:\\Desktop\\Test" | 200 | Auto |Bilinear| - -```powershell -rimage webp "C:\\test.png" --lossless --resize 200x_ --filter bilinear -d "C:\\Desktop\\Test" -``` ## Known bugs @@ -193,18 +182,18 @@ rimage webp "C:\\test.png" --lossless --resize 200x_ --filter bilinear -d "C:\\D This will crash: ```powershell -rimage png "D:\example.jpg" -d "D:\desktop\" -s "suffix" +rimage png "D:\example.jpg" -d "D:\desktop\" -s "_suf" ``` These will work as expected: ```powershell -rimage avif "D:\\example.jpg" -s "suffix" -d "D:\\desktop" # Highly Recommended -rimage moz "D:\\example.jpg" -s "suffix" -d "D:\\desktop\" # Recommended +rimage avif "D:\\example.jpg" -d "D:\\desktop" -s "_suf" # Highly Recommended +rimage webp "D:\\example.jpg" -d "D:\\desktop\\" -s "_suf" # Recommended -rimage jxl "D:\example.jpg" -d "D:\desktop" -b # Acceptable (Without trailing backslash) -rimage png "D:\example.jpg" --threads 4 -d "D:\desktop\" # Acceptable (Backslash at the end) -rimage webp "D:\example.jpg" -d ./desktop # Acceptable (Relative path) +rimage jxl "D:\example.jpg" -d "D:\desktop" -s "_suf" # Acceptable (Without trailing backslash) +rimage png "D:\example.jpg" -d "D:\desktop\" -s "_suf" # Acceptable (Backslash at the end) +rimage moz "D:\example.jpg" -d ./desktop -s "_suf" # Acceptable (Relative path) ``` ## Contributing From bf1ccca26365eb5a7652143a0e779d07ad8dd0d7 Mon Sep 17 00:00:00 2001 From: LinkChou Date: Wed, 24 Jul 2024 23:32:08 +0800 Subject: [PATCH 6/9] format cli.rs --- src/cli.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 9781feb..3d9ec92 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -12,9 +12,8 @@ pub mod utils; pub fn cli() -> Command { command!() .arg_required_else_help(true) - .after_help(indoc! {r#"List of supported codecs - - + .after_help(indoc! {r#" +List of supported codecs | Image Format | Input | Output | Note | | ------------- | ----- | ------ | --------------- | | avif | O | O | Static only | @@ -39,7 +38,8 @@ List of supported preprocessing options List of supported mode for output info presenting - No-progress (Shown on Default) -- Quiet (Show all msgs on Default)"#}) +- Quiet (Show all msgs on Default) +"#}) .codecs() } From 146a855cccfe94343b1490a176c17af45e747097 Mon Sep 17 00:00:00 2001 From: LinkChou Date: Wed, 24 Jul 2024 23:45:02 +0800 Subject: [PATCH 7/9] fix format check --- src/cli/common.rs | 2 +- src/cli/pipeline.rs | 2 +- src/cli/utils/paths/mod.rs | 2 +- src/main.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli/common.rs b/src/cli/common.rs index 1d3a6f9..e1c7420 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -69,4 +69,4 @@ impl CommonArgs for Command { pub trait CommonArgs { fn common_args(self) -> Self; -} \ No newline at end of file +} diff --git a/src/cli/pipeline.rs b/src/cli/pipeline.rs index 860daed..9f25a3f 100644 --- a/src/cli/pipeline.rs +++ b/src/cli/pipeline.rs @@ -390,4 +390,4 @@ pub fn encoder(name: &str, matches: &ArgMatches) -> Result>(path: P) -> Vec { } #[cfg(test)] -mod tests; \ No newline at end of file +mod tests; diff --git a/src/main.rs b/src/main.rs index d696f9f..b27c181 100644 --- a/src/main.rs +++ b/src/main.rs @@ -253,4 +253,4 @@ fn main() { } None => unreachable!(), } -} \ No newline at end of file +} From 3cf767ccf0e61c281d59b42fee0feb140a9193b9 Mon Sep 17 00:00:00 2001 From: LinkChou Date: Thu, 25 Jul 2024 01:06:37 +0800 Subject: [PATCH 8/9] docs: add warning info about --q and --d option in readme re-add cjk info --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a738351..382bb64 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ A powerful Rust image optimization CLI tool inspired by [squoosh!](https://squoo - Friendly output: - Rimage support progressbar - Rimage would show detailed error info to assist users +- CJK and Punctuation marks support: + - Rimage supports full CJK (Chinese, Japanese and Korean) characters input and output + - Rimage allows special punctuation characters such as `|`, ` `, `&`, `$`, etc. to be included in file names ## Installation @@ -159,9 +162,10 @@ For library usage check [Docs.rs](https://docs.rs/rimage/latest/rimage/) - No-progress (Shown on Default) - Quiet (Show all msgs on Default) -## Known bugs +## Known bugs & Warnings - **Dir path end with `\` may cause rimage crashes** due to a cmd bug [#72653](https://github.com/rust-lang/rust/issues/72653). +- Even if the value is set to 100, the quality of the image will still decrease if you use `--quantization` and(or) `--dithering` option(s). ### Example: From e6b4b61b8aa1a8e333b00d283693b4e62cab0d79 Mon Sep 17 00:00:00 2001 From: LinkChou Date: Fri, 26 Jul 2024 11:13:35 +0800 Subject: [PATCH 9/9] correct tiff infos --- README.md | 7 +++---- src/cli.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 382bb64..1a0eab2 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,6 @@ Commands: png Encode images into PNG format. ppm Encode images into PPM format. (Bitmapped) qoi Encode images into QOI format. (Trendy and Small) - tiff Encode images into TIFF format. webp Encode images into WebP format. (Lossless-able) help Print this message or the help of the given subcommand(s) @@ -139,16 +138,16 @@ For library usage check [Docs.rs](https://docs.rs/rimage/latest/rimage/) | Image Codecs | Decoder | Encoder | NOTE | | ------------ | ------------- | ----------------------- | ---------------------------------------------------- | | avif | libavif | ravif | Common features only, Static only | -| bmp | zune-bmp | X | Input only | +| bmp | zune-bmp | ❌ | Input only | | farbfeld | zune-farbfeld | zune-farbfeld | | | hdr | zune-hdr | zune-hdr | | | jpeg | zune-jpeg | mozjpeg or jpeg-encoder | Multifunctional when use mozjpeg encoder | | jpeg-xl | jxl-oxide | zune-jpegxl | Lossless only | | png | zune-png | oxipng or zune-png | Static only, Multifunctional when use oxipng encoder | | ppm | zune-ppm | zune-ppm | | -| psd | zune-psd | X | Input only | +| psd | zune-psd | ❌ | Input only | | qoi | zune-qoi | zune-qoi | | -| tiff | tiff | tiff | ??? | +| tiff | tiff | ❌ | Input only | | webp | webp | webp | Static only | ### List of supported preprocessing options diff --git a/src/cli.rs b/src/cli.rs index 3d9ec92..6fc5925 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -28,7 +28,7 @@ List of supported codecs | ppm | O | O | | | psd | O | X | | | qoi | O | O | | -| tiff | O | O | | +| tiff | O | X | | | webp | O | O | Static only | List of supported preprocessing options