diff options
author | gennyble <gen@nyble.dev> | 2023-10-09 20:20:16 -0500 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2023-10-09 20:20:16 -0500 |
commit | 3ad73998fe7bbb146aa124bc22729afe98d77c4c (patch) | |
tree | 6840a9bc9efc682df8133ca53274cffcb3654a86 | |
parent | db422e0c983d7543d4d5e742630b29e36c55cbd4 (diff) | |
download | colorsquash-3ad73998fe7bbb146aa124bc22729afe98d77c4c.tar.gz colorsquash-3ad73998fe7bbb146aa124bc22729afe98d77c4c.zip |
some docs
-rw-r--r-- | Cargo.toml | 14 | ||||
-rw-r--r-- | LICENSE | 15 | ||||
-rw-r--r-- | README.md | 17 | ||||
-rw-r--r-- | squash/Cargo.toml | 8 | ||||
-rw-r--r-- | src/lib.rs | 4 |
5 files changed, 36 insertions, 22 deletions
diff --git a/Cargo.toml b/Cargo.toml index dc8c6d0..a4f7347 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,22 +3,14 @@ name = "colorsquash" version = "0.1.0" authors = ["gennyble <gen@nyble.dev>"] edition = "2021" +license = "ISC" +description = "A crate for quantizing colours with preference to the most frequently occuring" +repository = "https://github.com/gennyble/colorsquash" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -#image = "0.23.14" -#ahash = "0.7.4" -#libc = "0.2.103" -#rayon = "*" rgb = "0.8.36" -#[dependencies.kmeans_colors] -#version = "0.3" -#default-features = false - -[profile.release] -debug = true - [workspace] members = ["squash"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8a55383 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright 2023 gennyble <gen@nyble.dev> + +Permission to use, copy, modify, and/or distribute this software for +any purposewith or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE +FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER +IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING +OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 288a923..fa69edc 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -Colorsquash is a colour quantization[^1] crate and algorithm. -At it's core, it sorts the unique colours that appear in an image -and selects the most frequent that are sufficiently different. - -To put it more clearly: -The most frequent colour is always selected and placed into the palette. -If the second most frequent colour is *different enough*, it will be selected -as well. If it's not, it is skipped and the third one is tried. This continues -until it selects the necessary amount of colours. +| 24bit RGB | 256 color Indexed| +| - | - | +| ![a small dog laying on a concrete floor in an industrial building](https://nyble.dev/colorsquash/astro.jpg) | ![the same image in 256 color. there are some visual differences, but the two images look very similar](https://nyble.dev/colorsquash/astro_squash.gif) | + +colorsquash is a colour quantization[^1] crate and algorithm. +At it's core, it sorts the colors of an image by how frequently +they appear, greatest to least. It then goes through those colours +and takes the top N colours that are sufficiently different. [^1]: [wikipedia: color quantization](https://en.wikipedia.org/wiki/Color_quantization) diff --git a/squash/Cargo.toml b/squash/Cargo.toml index 921f937..68fe712 100644 --- a/squash/Cargo.toml +++ b/squash/Cargo.toml @@ -1,14 +1,22 @@ [package] name = "squash" version = "0.1.0" +authors = ["gennyble <gen@nyble.dev>"] edition = "2021" +license = "ISC" +description = "CLI tool for quantizing colours" +repository = "https://github.com/gennyble/colorsquash/tree/main/squash" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +# the meat 'o the thing! the meaning behind it all colorsquash = { path = "..", version = "0.1.0" } + +# just useful tools for writing binaries anyhow = "1.0.75" camino = "1.1.6" + # time of writing: # png has a change to ignore extra iCCP blocks my test image needed. it hasn't # been released yet, so we're using the git here. the commit we require is e4b4811 diff --git a/src/lib.rs b/src/lib.rs index d4b852b..8d94c8e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ impl<T: Count> Default for SquasherBuilder<T> { Self { max_colours: T::from_usize(255), difference_fn: Box::new(difference::rgb_difference), - tolerance: 2.0, + tolerance: 1.0, } } } @@ -75,7 +75,7 @@ impl<T: Count> Squasher<T> { let mut this = Self::from_parts( max_colors_minus_one, Box::new(difference::rgb_difference), - 2.0, + 1.0, ); this.recolor(buffer); |