Crates.io | jp2k |
lib.rs | jp2k |
version | 0.3.1 |
source | src |
created_at | 2019-09-06 16:58:35.442058 |
updated_at | 2019-10-28 18:02:53.100795 |
description | Interface to load JPEG200 images into image |
homepage | |
repository | https://github.com/kardeiz/jp2k |
max_upload_size | |
id | 162830 |
size | 317,924 |
Supports loading JPEG2000 images into image::DynamicImage
.Rust
Forked from https://framagit.org/leoschwarz/jpeg2000-rust before its GPL-v3 relicensing, with some additional features:
This library brings its own libopenjpeg, which is statically linked. If you just need raw FFI bindings, see openjpeg2-sys or openjpeg-sys.
fn main() {
let bytes = include_bytes!("./rust-logo-512x512-blk.jp2");
let jp2k::Image(img) = jp2k::Image::from_bytes(
bytes,
jp2k::Codec::JP2,
Some(jp2k::DecodeParams::default().with_decoding_area(0, 0, 256, 256))
)
.unwrap();
let mut output = std::path::Path::new("examples/output/result.png");
let _ = img.save(&mut output);
}
Please be advised that using C code means this crate is likely vulnerable to various memory exploits, e.g. see http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-8332 for an actual example from the past.
As soon as someone writes an efficient JPEG2000 decoder in pure Rust you should probably switch over to that.
You can use the Rust code in the directories src
and openjp2-sys/src
under the terms of either the MIT license (LICENSE-MIT
file) or the Apache license (LICENSE-APACHE
file). Please note that this will link statically to OpenJPEG, which has its own license which you can find at openjpeg-sys/libopenjpeg/LICENSE
(you might have to check out the git submodule first).
License: MIT OR Apache-2.0