Skip to content

Delnegend/artefact

Repository files navigation

artefact

Decode JPEG without artifacts

  • Written in pure Rust, no unsafe code.
  • WASM-ready, check out the web version, everything runs in your browser.
  • ~3x FASTER than the of the original implementation jpeg2png project. (backup link)

Tests

Photo by Aleksandar Pasaric

Photo by Toa Heftiba Şinca

CLI version

1. Pre-build binaries

Get the latest release from the releases page.

2. Build guide

Pre-requisites: Rust toolchain

cargo build --release --package artefact-cli

The binary will be located at ./target/release/artefact-cli

Build features

To toggle specific features when building the CLI, modify artefact-cli/Cargo.toml and add the desired features to the [dependencies.artefact-lib] features list.

[dependencies.artefact-lib]
path = "../artefact-lib"
features = [
    "simd", # enable SIMD
    "simd_std", # using `std::simd` instead of `wide`
    "simd_adaptive", # dynamically switch between x8, x16, x32 and x64
    "native", # use LLVM "mul_add" intrinsic for more accurate rounding, requires "-Ctarget-cpu=native" or else it'll most likely be slower
    "moz", # use `mozjpeg` instead of `zune-jpeg` for decoding, might provide better compatibility
]

Recommendation: enable all first 4.

Cross-compile

  • Windows x64:
sudo apt update && sudo apt install gcc-mingw-w64-x86-64
rustup target add x86_64-pc-windows-gnu
nrr build-win-64
  • Windows x86:
sudo apt update && sudo apt install gcc-mingw-w64-i686
rustup target add i686-pc-windows-gnu
nrr build-win-32
  • Linux x86:
sudo dpkg --add-architecture i386
sudo apt update && sudo apt install -y gcc-multilib libc6-dev-i386
rustup target add i686-unknown-linux-gnu
nrr build-linux-32

Usage

Usage: artefact-cli [OPTIONS] <INPUT>

Arguments:
  <INPUT>
          The input jpeg file

Options:
  -o, --output <OUTPUT>
          The output png file

          Default: input file with png extension

  -f, --format <FORMAT>
          Output format

          Default: png Possible values: png, webp, tiff, bmp, gif

          [default: png]

  -y, --overwrite
          Overwrite existing output file

  -w, --weight <WEIGHT>
          Second order weight
          Higher values give smoother transitions with less staircasing

          Default: 0.3 for all channels, use comma separated values for each channel

  -p, --pweight <PWEIGHT>
          Probability weight
          Higher values make the result more similar to the source JPEG

          Default: 0.001 for all channels, use comma separated values for each channel

  -i, --iterations <ITERATIONS>
          Iterations
          Higher values give better results but take more time

          Default: 100 for all channels, use comma separated values for each channel

  -s, --spearate-components
          Separate components
          Separately optimize components instead of all together, exchanges quality for speed

  -b, --benchmark
          Benchmark mode

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

Developement

Directories

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.