Skip to content

Commit

Permalink
release: 3.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Oct 17, 2024
2 parents e5f1c80 + d2e7684 commit bedccbb
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 174 deletions.
34 changes: 17 additions & 17 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
# Project Dependencies
Package: flaca
Version: 3.1.8
Generated: 2024-09-12 18:28:44 UTC
Version: 3.1.9
Generated: 2024-10-17 20:53:40 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.11 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [argyle](https://github.com/Blobfolio/argyle) | 0.8.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [argyle](https://github.com/Blobfolio/argyle) | 0.10.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [bitvec](https://github.com/bitvecto-rs/bitvec) | 1.0.1 | | MIT |
| [bytecount](https://github.com/llogiq/bytecount) | 0.6.8 | [Andre Bogus](mailto:[email protected]) and [Joshua Landau](mailto:[email protected]) | Apache-2.0 or MIT |
| [bytemuck](https://github.com/Lokathor/bytemuck) | 1.18.0 | [Lokathor](mailto:[email protected]) | Apache-2.0, MIT, or Zlib |
| [bytemuck](https://github.com/Lokathor/bytemuck) | 1.19.0 | [Lokathor](mailto:[email protected]) | Apache-2.0, MIT, or Zlib |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [crc32fast](https://github.com/srijs/rust-crc32fast) | 1.4.2 | [Sam Rijs](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [crossbeam-channel](https://github.com/crossbeam-rs/crossbeam) | 0.5.13 | | Apache-2.0 or MIT |
| [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) | 0.8.20 | | Apache-2.0 or MIT |
| [ctrlc](https://github.com/Detegr/rust-ctrlc.git) | 3.4.5 | [Antti Keränen](mailto:[email protected]) | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.4 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dowser](https://github.com/Blobfolio/dowser) | 0.9.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [equivalent](https://github.com/cuviper/equivalent) | 1.0.1 | | Apache-2.0 or MIT |
| [fastrand](https://github.com/smol-rs/fastrand) | 2.1.1 | [Stjepan Glavina](mailto:[email protected]) | Apache-2.0 or MIT |
| flapfli | 3.1.8 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| flapfli | 3.1.9 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [funty](https://github.com/myrrlyn/funty) | 2.0.0 | [myrrlyn](mailto:[email protected]) | MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.14.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.14.5 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
| [indexmap](https://github.com/indexmap-rs/indexmap) | 2.5.0 | | Apache-2.0 or MIT |
| [libc](https://github.com/rust-lang/libc) | 0.2.158 | The Rust Project Developers | Apache-2.0 or MIT |
| [libdeflate-sys](https://github.com/adamkewley/libdeflater) | 1.21.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
| [libdeflater](https://github.com/adamkewley/libdeflater) | 1.21.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 1.1.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.15.0 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
| [indexmap](https://github.com/indexmap-rs/indexmap) | 2.6.0 | | Apache-2.0 or MIT |
| [libc](https://github.com/rust-lang/libc) | 0.2.161 | The Rust Project Developers | Apache-2.0 or MIT |
| [libdeflate-sys](https://github.com/adamkewley/libdeflater) | 1.22.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
| [libdeflater](https://github.com/adamkewley/libdeflater) | 1.22.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
| [log](https://github.com/rust-lang/log) | 0.4.22 | The Rust Project Developers | Apache-2.0 or MIT |
| [mozjpeg-sys](https://github.com/kornelski/mozjpeg-sys.git) | 2.2.1 | [Kornel](mailto:[email protected]) | IJG AND Zlib AND BSD-3-Clause |
| [once_cell](https://github.com/matklad/once_cell) | 1.19.0 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
| [once_cell](https://github.com/matklad/once_cell) | 1.20.2 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
| [oxipng](https://github.com/shssoichiro/oxipng) | 9.1.2 | [Joshua Holmer](mailto:[email protected]) | MIT |
| [radium](https://github.com/bitvecto-rs/radium) | 0.7.0 | [Nika Layzell](mailto:[email protected]) and [myrrlyn](mailto:[email protected]) | MIT |
| [rgb](https://github.com/kornelski/rust-rgb) | 0.8.50 | [Kornel Lesiński](mailto:[email protected]) and [James Forster](mailto:[email protected]) | MIT |
| [rustc-hash](https://github.com/rust-lang-nursery/rustc-hash) | 1.1.0 | The Rust Project Developers | Apache-2.0 or MIT |
| [tap](https://github.com/myrrlyn/tap) | 1.0.1 | [Elliott Linder](mailto:[email protected]) and [myrrlyn](mailto:[email protected]) | MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.12.0 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [terminal_size](https://github.com/eminence/terminal-size) | 0.3.0 | [Andrew Chin](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.13 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.9.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.13.0 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [terminal_size](https://github.com/eminence/terminal-size) | 0.4.0 | [Andrew Chin](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.2.0 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.10.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [wyz](https://github.com/myrrlyn/wyz) | 0.5.1 | [myrrlyn](mailto:[email protected]) | MIT |
| [zerocopy](https://github.com/google/zerocopy) | 0.7.35 | [Joshua Liebow-Feeser](mailto:[email protected]) | Apache-2.0, BSD-2-Clause, or MIT |
15 changes: 8 additions & 7 deletions flaca/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flaca"
version = "3.1.8"
version = "3.1.9"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand Down Expand Up @@ -111,22 +111,26 @@ items = [
[ "Zopflipng", "<https://github.com/google/zopfli>" ]
]

[build-dependencies]
argyle = "0.10.*"
dowser = "0.9.*"

[dependencies]
argyle = "0.8.*"
argyle = "0.10.*"
crossbeam-channel = "=0.5.*"
ctrlc = "=3.4.5"
dactyl = "0.7.*"
dowser = "0.9.*"
libc = "0.2.*"
utc2k = "0.9.*"
utc2k = "0.10.*"
write_atomic = "0.5.*"

[dependencies.flapfli]
version = "*"
path = "../flapfli"

[dependencies.fyi_msg]
version = "0.14.*"
version = "1.1.*"
features = [ "progress" ]

[dependencies.mozjpeg-sys]
Expand All @@ -138,6 +142,3 @@ features = [ "jpegtran", "nasm_simd", "unwinding" ]
version = "=9.1.2"
default-features = false
features = [ "freestanding" ]

[build-dependencies]
dowser = "0.9.*"
21 changes: 21 additions & 0 deletions flaca/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Flaca - Build
*/

use argyle::KeyWordsBuilder;
use dowser::Extension;
use std::{
fs::File,
Expand All @@ -23,9 +24,29 @@ pub fn main() {
#[cfg(not(target_pointer_width = "64"))]
panic!("Flaca requires a 64-bit CPU architecture.");

build_cli();
build_exts();
}

/// # Build CLI Arguments.
fn build_cli() {
let mut builder = KeyWordsBuilder::default();
builder.push_keys([
"-h", "--help",
"--no-jpg", "--no-jpeg",
"--no-png",
"-p", "--progress",
"-V", "--version",
]);
builder.push_keys_with_values([
"-j",
"-l", "--list",
"--max-resolution",
"-z",
]);
builder.save(out_path("argyle.rs"));
}

/// # Pre-Compute Extensions.
///
/// We might as well generate the path-matching constants while we're here.
Expand Down
95 changes: 86 additions & 9 deletions flaca/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Flaca: Errors
*/

use argyle::ArgyleError;
use fyi_msg::ProglessError;
use std::{
error::Error,
Expand All @@ -11,21 +10,95 @@ use std::{



/// # Help Text.
const HELP: &str = concat!(r"
,--._,--.
,' ,' ,-`.
(`-.__ / ,' /
`. `--' \__,--'-.
`--/ ,-. ______/
(o-. ,o- /
`. ; \ ", "\x1b[38;5;199mFlaca\x1b[0;38;5;69m v", env!("CARGO_PKG_VERSION"), "\x1b[0m", r#"
|: \ Brute-force, lossless
,'` , \ JPEG and PNG compression.
(o o , --' :
\--','. ;
`;; : /
;' ; ,' ,'
,',' : '
\ \ :
`
USAGE:
flaca [FLAGS] [OPTIONS] <PATH(S)>...
FLAGS:
-h, --help Print help information and exit.
--no-jpeg Skip JPEG images.
--no-png Skip PNG images.
-p, --progress Show pretty progress while minifying.
-V, --version Print version information and exit.
OPTIONS:
-j <NUM> Limit parallelization to this many threads (instead of
giving each logical core its own image to work on). If
negative, the value will be subtracted from the total
number of logical cores.
-l, --list <FILE> Read (absolute) image and/or directory paths from this
text file — or STDIN if "-" — one entry per line, instead
of or in addition to (actually trailing) <PATH(S)>.
--max-resolution <NUM>
Skip images containing more than <NUM> total pixels to
avoid potential OOM errors during decompression.
[default: ~4.29 billion]
-z <NUM> Run NUM lz77 backward/forward iterations during zopfli
PNG encoding passes. More iterations yield better
compression (up to a point), but require *significantly*
longer processing times. In practice, values beyond 500
are unlikely to save more than a few bytes, and could
take *days* to complete! Haha. [default: 20 or 60,
depending on the file size]
ARGS:
<PATH(S)>... One or more image and/or directory paths to losslessly
compress.
EARLY EXIT:
Press "#, "\x1b[38;5;208mCTRL\x1b[0m+\x1b[38;5;208mC\x1b[0m once to quit as soon as the already-in-progress operations
have finished (ignoring any pending images still in the queue).
Press \x1b[38;5;208mCTRL\x1b[0m+\x1b[38;5;208mC\x1b[0m a second time if you need to exit IMMEDIATELY, but note that
doing so may leave artifacts (temporary files) behind, and in rare cases,
lead to image corruption.
OPTIMIZERS USED:
MozJPEG <https://github.com/mozilla/mozjpeg>
Oxipng <https://github.com/shssoichiro/oxipng>
Zopflipng <https://github.com/google/zopfli>
");



#[derive(Debug, Copy, Clone)]
/// # Encoding Errors.
pub(super) enum EncodingError {
/// # Empty File.
Empty,

/// # Wrong/Unknown Format.
Format,

/// # Read Error.
Read,

/// # Resolution.
Resolution,

/// # Intentionally Skipped.
Skipped,

/// # Vanished.
Vanished,

/// # Write Error.
Write,
}
Expand All @@ -51,18 +124,26 @@ impl EncodingError {
#[derive(Debug, Copy, Clone)]
/// # General/Deal-Breaking Errors.
pub(super) enum FlacaError {
/// # Argyle Passthrough.
Argue(ArgyleError),
/// # Killed Early.
Killed,

/// # No Images.
NoImages,

/// # Max Resolution.
MaxResolution,

/// # Progress Passthrough.
Progress(ProglessError),

/// # Invalid Zopfli Iterations.
ZopfliIterations,

/// # Print Help (Not an Error).
PrintHelp,

/// # Print Version (Not an Error).
PrintVersion,
}

impl AsRef<str> for FlacaError {
Expand All @@ -79,11 +160,6 @@ impl fmt::Display for FlacaError {
}
}

impl From<ArgyleError> for FlacaError {
#[inline]
fn from(err: ArgyleError) -> Self { Self::Argue(err) }
}

impl From<ProglessError> for FlacaError {
#[inline]
fn from(err: ProglessError) -> Self { Self::Progress(err) }
Expand All @@ -94,12 +170,13 @@ impl FlacaError {
/// # As Str.
pub(super) const fn as_str(self) -> &'static str {
match self {
Self::Argue(e) => e.as_str(),
Self::Killed => "The process was aborted early.",
Self::NoImages => "No images were found.",
Self::MaxResolution => "Pixel limits must be between 1..=4_294_967_295.",
Self::Progress(e) => e.as_str(),
Self::ZopfliIterations => "The number of (zopfli) lz77 iterations must be between 1..=2_147_483_647.",
Self::PrintHelp => HELP,
Self::PrintVersion => concat!("Flaca v", env!("CARGO_PKG_VERSION")),
}
}
}
13 changes: 13 additions & 0 deletions flaca/src/image/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Flaca: Image Kind
*/

use crate::FlacaError;
use std::num::NonZeroU32;


Expand All @@ -25,6 +26,18 @@ pub(crate) enum ImageKind {
}

impl ImageKind {
/// # Return the Difference.
///
/// Subtract `other` from `self`, returning an error if that leaves
/// nothing.
pub(crate) const fn diff(self, other: Self) -> Result<Self, FlacaError> {
match other {
Self::Jpeg if matches!(self, Self::All | Self::Png) => Ok(Self::Png),
Self::Png if matches!(self, Self::All | Self::Jpeg) => Ok(Self::Jpeg),
_ => Err(FlacaError::NoImages),
}
}

#[expect(clippy::inline_always, reason = "For performance.")]
#[inline(always)]
/// # Supports JPEG?
Expand Down
Loading

0 comments on commit bedccbb

Please sign in to comment.