Comments (6)
The difference is due to chroma subsampling.
compressor.components_mut()
has component.h_samp_factor
and .v_samp_factor
Search v_samp_factor here for more info https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/libjpeg.txt
from mozjpeg-rust.
The difference is due to chroma subsampling.
compressor.components_mut()
hascomponent.h_samp_factor
and.v_samp_factor
Search v_samp_factor here for more info https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/libjpeg.txt
Thanks for your reponse! Do I understand it right that I should disable subsampling in order to achieve the desired result? I modified my code in the following way:
let mut compressor = Compress::new(ColorSpace::JCS_EXT_RGBA);
compressor.set_quality(30.0);
compressor.set_size(320, 240);
let mut components = compressor.components_mut();
for component in components {
component.h_samp_factor = 1;
component.v_samp_factor = 1;
}
compressor.set_mem_dest();
compressor.start_compress();
compressor.write_scanlines(&scanlines);
compressor.finish_compress();
It led to a result that is closer to what I need, but still not quite the same:
from mozjpeg-rust.
The rest is up to quality setting.
MozJPEG defaults to quantization table optimized for photographic content, and not icons with sharp edges.
from mozjpeg-rust.
The rest is up to quality setting.
MozJPEG defaults to quantization table optimized for photographic content, and not icons with sharp edges.
I tried specifying every possible value for -quant-table
argument and no result was the same as libjpeg. This is the command I used:
djpeg original.jpg | cjpeg -quality 30 -quant-table <N> -sample 1x1 > libjpeg_30.jpg
However, then I noticed that -revert
param does the trick:
djpeg original.jpg | cjpeg -revert -quality 30 > libjpeg_30.jpg
For those wondering how to do it in Rust code, you need to call Compress::set_fastest_defaults()
method. It needs to be called before you set quality or other settings, otherwise it will overwrite them.
from mozjpeg-rust.
Please note that -revert
/fastest_defaults
disables all compression improvements too. It completely turns off all MozJPEG features, as if didn't exist. You get plain libjpeg-turbo with an old encoder.
from mozjpeg-rust.
Please note that
-revert
/fastest_defaults
disables all compression improvements too. It completely turns off all MozJPEG features, as if didn't exist. You get plain libjpeg-turbo with an old encoder.
Thanks for clarifying that. At the current stage of my project this is exactly what I need, but later I'll be able to turn MozJPEG features back on as I won't need to match images produced by libjpeg
anymore.
from mozjpeg-rust.
Related Issues (15)
- DecompressScanlines::read_scanlines is unsound HOT 2
- wasm-pack build error HOT 9
- Add some encoding examples HOT 3
- Add mozjpeg-rust as encoder to image crate HOT 1
- Decoding isn't reporting decode errors back to application HOT 7
- Encoding fails on macOS arm64 (bus error) HOT 5
- Ability to change subsampling mode HOT 1
- Equivalent of jpegtran -optimize HOT 2
- Please release a new version on Crates.io HOT 2
- Add ability to enable full JPEG baseline compatibility HOT 2
- mozjpeg can unwind through `extern "C" fn` boundary, which is UB HOT 2
- could not build staticlib HOT 6
- Ability to write icc profile HOT 2
- How to get error message? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mozjpeg-rust.