Comments (7)
Which version of Rust are you using?
Does cargo test
in this repo pass on your machine?
from mozjpeg-rust.
cargo 1.47.0 (f3c7e066a 2020-08-28)
Cargo tests all pass.
The Cargo.lock for my test program was:
[[package]]
name = "mozjpeg"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1d3a4f737389e9512b662e4f2c412761919994203874e2366afa97927865b27"
dependencies = [
"arrayvec",
"libc",
"mozjpeg-sys",
"rgb",
]
I've also retried by using a fresh clone of the github repo: mozjpeg = {version= "*", path="../mozjpeg-rust" }
, and the results are the same.
i've attached the test image. A quick way to verify that it fails decoding with libturbojpeg is to run djpeg -outfile /dev/null file.jpg
from mozjpeg-rust.
There is a test for error handling:
Line 20 in 8b93d48
All errors are handled by the same error handler, so I don't see why one error would work differently than another.
from mozjpeg-rust.
Oh, I see. djpeg
is not failing. It prints a warning, but still generates an image. The library has identical behavior.
from mozjpeg-rust.
I see what you mean. But as a library, that warning info should be available to the programmer, not just get printed to stderr, no? (Did I miss a part of the API that provides access to that warning?)
(My usecase is that I'm trying to validate that a JPEG hasn't gotten corrupted, and this is one of the examples where it's getting corrupted but the handling of that error varies considerably by platform. As you note, djpeg just prints out a warning. The python bindings for libjpegturbo throw an exception. Python PIL silently accepts it. Chrome will render it with lots of blank grey. The go standard library jpeg decoder returns an error trying to parse it ('invalid JPEG format: missing 0xff00 sequence').
I'm completely sympathetic that there are times when presenting a partial decode is better -- a browser, for example -- but there are also times when it's awesome to be able to be strict.
from mozjpeg-rust.
libjpeg makes this a warning callback:
https://github.com/mozilla/mozjpeg/blob/d23e3fc58613bc3f0aa395a8c73a2b1e7dae9e25/jerror.h#L267-L269
I haven't exposed a high-level rusty interface for this callback.
from mozjpeg-rust.
This is an amazing quirk of libjpeg. It detects end of file, and then pretends there's infinitely more faked data in the file that happens to be EOI marker over and over again.
This code has been there since 1994, so this is very much a case of working as expected.
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
- How to achieve same quality as libjpeg? HOT 6
- Add mozjpeg-rust as encoder to image crate HOT 1
- 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.