Skip to content

Commit 2d444b7

Browse files
dimlevwash2
authored andcommitted
Increase memory limit for image decoding
1 parent 13caa40 commit 2d444b7

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/wallpaper.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111

1212
use cosmic_bg_config::{Color, Entry, SamplingMethod, ScalingMode, Source, state::State};
1313
use cosmic_config::CosmicConfigEntry;
14-
use image::{DynamicImage, ImageReader};
14+
use image::{DynamicImage, ImageReader, Limits};
1515
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
1616
use rand::{rng, seq::SliceRandom};
1717
use sctk::reexports::{
@@ -130,15 +130,21 @@ impl Wallpaper {
130130
.ok()
131131
.and_then(|f| f.with_guessed_format().ok())
132132
{
133-
Some(f) => match f.decode() {
134-
Ok(img) => Some(img),
135-
Err(why) => {
136-
tracing::warn!(
137-
?why,
138-
"Failed to decode image: {}",
139-
path.display()
140-
);
141-
continue;
133+
Some(mut f) => {
134+
let mut limits = Limits::default();
135+
limits.max_alloc = Some(1024 * 1024 * 1024);
136+
f.limits(limits);
137+
138+
match f.decode() {
139+
Ok(img) => Some(img),
140+
Err(why) => {
141+
tracing::warn!(
142+
?why,
143+
"Failed to decode image: {}",
144+
path.display()
145+
);
146+
continue;
147+
}
142148
}
143149
},
144150
None => continue,

0 commit comments

Comments
 (0)