What Is the Default Quality Setting for ImageKit? A Complete Guide
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.
In this file, the quality argument uses the default_value_t = 85 attribute, ensuring that every execution automatically assumes quality 85 unless explicitly overridden:
// 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, 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:
./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:
./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:
./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
-qflag is omitted. - Source location: The default is defined in
src/cli.rswithdefault_value_t = 85. - Processing impact: The value controls JPEG quantization and PNG compression strategies in
src/processor.rs. - Override method: Use
-qor--qualityfollowed 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, 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, 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.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →