improve build times by extracting asset opt into its own crate (#3273)
* improve build types by extracing asset opt as a dylib * dont use dylib, but let regular workspace caching do the heavy lifting * add prebuild to cli for better lock contention * hoist deps * disable slow tests * re-enable sequential, debug=0 for dev * use vfs for windows * dont cache on failure, fix windows vfs caceh * free disk space re-order * add clippy + fmt to windows channel * yoink makefile * proper rustfmt/clippy on toolchain * set incremental to zero since cargo-cache disables it
This commit is contained in:
1 parent
79a2f023e7
commit
1cbfcde6cd
25 files changed
+550
-554
No files matched your search
@@ -0,0 +1,23 @@
|
||||
use image::{DynamicImage, EncodableLayout};
|
||||
use std::{
|
||||
io::{BufWriter, Write},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
pub(crate) fn compress_jpg(image: DynamicImage, output_location: &Path) -> anyhow::Result<()> {
|
||||
let mut comp = mozjpeg::Compress::new(mozjpeg::ColorSpace::JCS_EXT_RGBX);
|
||||
let width = image.width() as usize;
|
||||
let height = image.height() as usize;
|
||||
|
||||
comp.set_size(width, height);
|
||||
let mut comp = comp.start_compress(Vec::new())?; // any io::Write will work
|
||||
|
||||
comp.write_scanlines(image.to_rgba8().as_bytes())?;
|
||||
|
||||
let jpeg_bytes = comp.finish()?;
|
||||
|
||||
let file = std::fs::File::create(output_location)?;
|
||||
let w = &mut BufWriter::new(file);
|
||||
w.write_all(&jpeg_bytes)?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user