Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xcommon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "Apache-2.0 OR MIT"
anyhow = "1.0.68"
byteorder = "1.4.3"
dunce = "1"
image = { version = "0.24.5", default-features = false, features = ["png", "webp"] }
image = { version = "0.25.2", default-features = false, features = ["png", "webp"] }
pem = "1.1.0"
rasn = "0.6.1"
rasn-pkix = "0.6.0"
Expand Down
7 changes: 3 additions & 4 deletions xcommon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ pub mod llvm;
use anyhow::{Context, Result};
use byteorder::{LittleEndian, ReadBytesExt};
use image::imageops::FilterType;
use image::io::Reader as ImageReader;
use image::{DynamicImage, GenericImageView, ImageOutputFormat, RgbaImage};
use image::{DynamicImage, GenericImageView, ImageFormat, ImageReader, RgbaImage};
use rsa::pkcs8::DecodePrivateKey;
use rsa::{PaddingScheme, RsaPrivateKey, RsaPublicKey};
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -64,13 +63,13 @@ impl Scaler {
.img
.resize(opts.scaled_size, opts.scaled_size, FilterType::Nearest);
if opts.scaled_size == opts.target_width && opts.scaled_size == opts.target_height {
resized.write_to(w, ImageOutputFormat::Png)?;
resized.write_to(w, ImageFormat::Png)?;
} else {
let x = (opts.target_width - opts.scaled_size) / 2;
let y = (opts.target_height - opts.scaled_size) / 2;
let mut padded = RgbaImage::new(opts.target_width, opts.target_height);
image::imageops::overlay(&mut padded, &resized, x as i64, y as i64);
padded.write_to(w, ImageOutputFormat::Png)?;
padded.write_to(w, ImageFormat::Png)?;
}
Ok(())
}
Expand Down
Loading