Skip to content

Commit

Permalink
Merge pull request #128 from Mikachu2333/main
Browse files Browse the repository at this point in the history
add -t option and more description
  • Loading branch information
SalOne22 committed Oct 15, 2023
2 parents 9060121 + 13c30b3 commit 8410dc8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ Options:
-V, --version Print version
General:
-q, --quality <QUALITY> Optimization quality
-q, --quality <QUALITY> Optimization image quality
[range: 1 - 100] [default: 75]
-f, --codec <CODEC> Image codec to use
[default: mozjpeg] [possible values: png, oxipng, jpegxl, webp, avif]
-o, --output <DIR> Write output file(s) to <DIR>
[default: jpg] [possible values: png, oxipng, jpegxl, webp, avif]
-o, --output <DIR> Write output file(s) to <DIR>, if "-r" option is not used
-r, --recursive Saves output file(s) preserving folder structure
-s, --suffix [<SUFFIX>] Appends suffix to output file(s) names
-b, --backup Appends ".backup" to input file(s) names
-b, --backup Appends ".backup" suffix to input file(s) extension
-t, --threads Number of threads to use, more will run faster, but too many may crash
[range: 1 - 16] [integer only] [default: number of cores]
Quantization:
--quantization [<QUALITY>] Enables quantization with optional quality
Expand All @@ -63,7 +65,7 @@ Resizing:
--height <HEIGHT> Resize image with specified height
[integer only]
--filter <FILTER> Filter used for image resizing
[default: lanczos3] [possible values: point, triangle, catmull-rom, mitchell]
[possible values: point, triangle, catrom, mitchell] [default: lanczos3]
```

Note that image formats may wary from features that are used when building `rimage`.
Expand Down Expand Up @@ -107,14 +109,14 @@ rimage.exe "D:\\Desktop\\input [text].png" -q 90 -f jpg -o "D:\\Desktop\\OutputT
rimage.exe "C:\\中 文\\ソフトウェア.PNG" -q 40 --codec png -s "_문자" -r --quantization 95 --dithering 85
```

### jpg => webp & resize width and height (both are opinional)
### jpg => webp & threads &resize width and height (both are opinional)

|Image Path|Quality|Out Format|Out Dir|Width|Height|
|----|----|----|----|----|---|
|"C:\\Docs\\justfortest.JPG"|40|webp|"C:\\Desktop\\Test"|60|10|
|Image Path|Quality|Out Format|Out Dir|Threads|Width|Height|
|----|----|----|----|----|----|----|
|"C:\\Docs\\justfortest.JPG"|40|webp|"C:\\Desktop\\Test"|4|60|10|

```sh
rimage.exe "C:\\Docs\\justfortest.PNG" --quality 40 --codec webp --output "C:\\Desktop\\Test" --width 60 --height 10
rimage.exe "C:\\Docs\\justfortest.PNG" --quality 40 --codec webp --output "C:\\Desktop\\Test" --threads 4 --width 60 --height 10
```

## Library Installation
Expand All @@ -129,7 +131,7 @@ Or add this to your `Cargo.toml`:

```toml
[dependencies]
rimage = "0.9.0"
rimage = "0.8.0"
```

## Library Usage
Expand Down
18 changes: 9 additions & 9 deletions src/bin/rimage/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,39 @@ fn main() -> Result<(), Box<dyn Error>> {
)
.next_help_heading("General")
.args([
arg!(-q --quality <QUALITY> "Optimization quality")
arg!(-q --quality <QUALITY> "Optimization image quality\n[range: 1 - 100]")
.value_parser(value_parser!(f32))
.default_value("75"),
arg!(-f --codec <CODEC> "Image codec to use")
arg!(-f --codec <CODEC> "Image codec to use\n[possible values: png, oxipng, jpegxl, webp, avif]")
.value_parser(Codec::from_str)
.default_value("mozjpeg"),
arg!(-o --output <DIR> "Write output file(s) to <DIR>")
arg!(-o --output <DIR> "Write output file(s) to <DIR>, if \"-r\" option is not used")
.value_parser(value_parser!(PathBuf)),
arg!(-r --recursive "Saves output file(s) preserving folder structure")
.action(ArgAction::SetTrue),
arg!(-s --suffix [SUFFIX] "Appends suffix to output file(s) names"),
arg!(-b --backup "Appends '.backup' to input file(s) names")
arg!(-b --backup "Appends \".backup\" suffix to input file(s) extension")
.action(ArgAction::SetTrue),
#[cfg(feature = "parallel")]
arg!(-t --threads "Number of threads to use [default: number of cores]")
.value_parser(value_parser!(usize)),
])
.next_help_heading("Quantization")
.args([
arg!(--quantization [QUALITY] "Enables quantization with optional quality [default: 75]")
arg!(--quantization [QUALITY] "Enables quantization with optional quality\n[range: 1 - 100] [default: 75]")
.value_parser(value_parser!(u8).range(..=100))
.default_missing_value("75"),
arg!(--dithering [QUALITY] "Enables dithering with optional quality [default: 75]")
arg!(--dithering [QUALITY] "Enables dithering with optional quality\n[range: 1 - 100] [default: 75]")
.value_parser(value_parser!(f32))
.default_missing_value("75")
])
.next_help_heading("Resizing")
.args([
arg!(--width <WIDTH> "Resize image with specified width")
arg!(--width <WIDTH> "Resize image with specified width\n[integer only]")
.value_parser(value_parser!(usize)),
arg!(--height <HEIGHT> "Resize image with specified height")
arg!(--height <HEIGHT> "Resize image with specified height\n[integer only]")
.value_parser(value_parser!(usize)),
arg!(--filter <FILTER> "Filter used for image resizing")
arg!(--filter <FILTER> "Filter used for image resizing\n[possible values: point, triangle, catrom, mitchell] [default: lanczos3]")
.value_parser(ResizeType::from_str)
.default_value("lanczos3")
])
Expand Down

0 comments on commit 8410dc8

Please sign in to comment.