Skip to content

Commit

Permalink
fix: resize image if too big
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanabx committed Apr 14, 2024
1 parent 9a14072 commit f9944a7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ impl Daemon {
.decode()
{
log::info!("{} is a valid image", name);
if img.width() != img.height() {
log::error!(
"Image width and height are different! {} != {}",
img.width(),
img.height()
);
return false;
}
let img = if img.width() > 512 {
log::warn!("Image size was greater than 512! Resizing icon to 512x512.");
img.resize(512, 512, image::imageops::FilterType::Lanczos3)
} else {
img
};
let image_size_dir = format!("{}x{}", img.width(), img.height());
let _ = create_dir_all(self.data_dir.join(Path::new(&format!(
"icons/hicolor/{}/apps/",
Expand Down

0 comments on commit f9944a7

Please sign in to comment.