# What Is the Default Quality Setting for ImageKit? A Complete Guide

> Discover the default quality setting for ImageKit. Learn how ImageKit handles JPEG and PNG images without explicit quality flags and optimize your image delivery.

- Repository: [hzbd/imagekit](https://github.com/hzbd/imagekit)
- Tags: how-to-guide
- Published: 2026-03-03

---

**ImageKit uses a default output quality of 85 for JPEG and PNG images when the `-q` or `--quality` flag is not supplied.**

The hzbd/imagekit repository is a Rust-based CLI tool for batch image processing that automatically applies conservative compression settings to balance visual fidelity and file size. Understanding the default quality setting helps you predict output file sizes and visual clarity before running your first conversion command.

## Where the Default Quality Is Defined

The default value of **85** is hardcoded in the command-line interface definition within [`src/cli.rs`](https://github.com/hzbd/imagekit/blob/main/src/cli.rs). 

In this file, the `quality` argument uses the `default_value_t = 85` attribute, ensuring that every execution automatically assumes quality 85 unless explicitly overridden:

```rust
// Located in src/cli.rs, lines 36-38
#[arg(short, long, default_value_t = 85)]
quality: u8,

```

This default value is also documented in the project's README.md, confirming that **85** is the intended baseline for all JPEG and PNG output operations.

## How the Default Quality Affects Image Processing

Once parsed, the quality value propagates to [`src/processor.rs`](https://github.com/hzbd/imagekit/blob/main/src/processor.rs), where it directly influences the encoding parameters for both JPEG and PNG formats.

- **JPEG encoding**: The value maps to the JPEG quality parameter (0-100 scale), controlling quantization table selection and compression ratios.
- **PNG compression**: While PNG uses lossless compression, the quality setting affects internal zlib compression levels and filtering strategies to optimize file size.

The default of 85 strikes a balance that typically reduces file sizes by 30-50% compared to quality 100 while maintaining visually lossless results for most photographic content.

## Changing the Default Quality Setting

You can override the default 85 value using the `-q` or `--quality` flag followed by any integer between 1 and 100.

### Using the Default Quality (85)

Run ImageKit without the quality flag to automatically apply the default setting:

```bash
./target/release/imagekit \
    -i example/img-src \
    -o example/img-out \
    --width 1024

```

Images processed with this command receive quality 85 compression, producing smaller files suitable for web delivery without noticeable artifacts.

### Specifying a Custom Quality

Increase quality to 100 for archival purposes or maximum fidelity:

```bash
./target/release/imagekit \
    -i example/img-src \
    -o example/img-out \
    --width 1024 \
    -q 100

```

Conversely, reduce quality below 85 to prioritize bandwidth savings over image clarity:

```bash
./target/release/imagekit \
    -i example/img-src \
    -o example/img-out \
    --width 1024 \
    -q 70

```

## Summary

- **Default value**: ImageKit automatically applies quality 85 when the `-q` flag is omitted.
- **Source location**: The default is defined in [`src/cli.rs`](https://github.com/hzbd/imagekit/blob/main/src/cli.rs) with `default_value_t = 85`.
- **Processing impact**: The value controls JPEG quantization and PNG compression strategies in [`src/processor.rs`](https://github.com/hzbd/imagekit/blob/main/src/processor.rs).
- **Override method**: Use `-q` or `--quality` followed by a value between 1 and 100 to customize output fidelity.

## Frequently Asked Questions

### What happens if I set quality above 100 or below 1?

ImageKit validates the quality parameter against valid u8 ranges (0-255) in [`src/cli.rs`](https://github.com/hzbd/imagekit/blob/main/src/cli.rs), but logically expects values between 1 and 100. Supplying values outside this range may cause the Rust type system to reject the input or produce unexpected compression behavior in the image encoders.

### Does the default quality of 85 apply to all image formats?

According to the source code in [`src/processor.rs`](https://github.com/hzbd/imagekit/blob/main/src/processor.rs), the quality parameter primarily affects JPEG and PNG outputs. Other formats supported by the underlying image libraries may ignore this value if they use inherently lossless compression methods that do not accept quality parameters.

### Why did the developers choose 85 as the default instead of 90 or 100?

Quality 85 represents the industry-standard sweet spot where chroma subsampling and quantization reduce file sizes significantly while remaining perceptually identical to the source for most use cases. Values above 90 produce diminishing returns in visual quality while increasing file sizes exponentially.

### How can I verify the quality setting was applied to my output images?

Check the command output logs or use external tools like `identify -verbose` (ImageMagick) or `exiftool` to inspect the JPEG quality estimate metadata. While ImageKit does not embed the quality value in output metadata headers, you can compare file sizes between default (85) and maximum (100) runs to confirm compression levels.