Skip to content

Commit dabef1a

Browse files
committed
Merge upstream COSMIC 1.5 into wmde-bg
Brings in one upstream commit: apply EXIF orientation when decoding a wallpaper (upstream pop-os#142). The merge was clean with a single auto-merged conflict in src/wallpaper.rs (no manual resolution needed) - decode() now reads orientation from the image decoder and applies it to the DynamicImage before use. No Cargo.toml version bump needed (both sides already at 1.2.0), no i18n .ftl files in this crate, and no debian/ resurrection. Brand sweep found only pre-existing internal CosmicBg/CosmicConfigEntry type names (load-bearing, not rebrand leftovers) - nothing to change.
2 parents 7886c98 + 76e89e6 commit dabef1a

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

src/wallpaper.rs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::{CosmicBg, CosmicBgLayer};
44

55
use std::collections::VecDeque;
66
use std::fs;
7+
use std::io::BufReader;
78
use std::path::PathBuf;
89
use std::time::{Duration, Instant};
910

1011
use wmde_bg_config::state::State;
1112
use wmde_bg_config::{Color, Entry, SamplingMethod, ScalingMode, Source};
1213
use cosmic_config::CosmicConfigEntry;
13-
use image::{DynamicImage, ImageReader, Limits};
14+
use image::{DynamicImage, ImageDecoder, ImageReader, ImageResult, Limits};
1415
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
1516
use rand::rng;
1617
use rand::seq::SliceRandom;
@@ -126,23 +127,17 @@ impl Wallpaper {
126127
.ok()
127128
.and_then(|f| f.with_guessed_format().ok())
128129
{
129-
Some(mut f) => {
130-
let mut limits = Limits::default();
131-
limits.max_alloc = Some(1024 * 1024 * 1024);
132-
f.limits(limits);
133-
134-
match f.decode() {
135-
Ok(img) => Some(img),
136-
Err(why) => {
137-
tracing::warn!(
138-
?why,
139-
"Failed to decode image: {}",
140-
path.display()
141-
);
142-
continue;
143-
}
130+
Some(f) => match decode(f) {
131+
Ok(img) => Some(img),
132+
Err(why) => {
133+
tracing::warn!(
134+
?why,
135+
"Failed to decode image: {}",
136+
path.display()
137+
);
138+
continue;
144139
}
145-
}
140+
},
146141
None => continue,
147142
};
148143
}
@@ -349,6 +344,23 @@ impl Wallpaper {
349344
}
350345
}
351346

347+
fn decode(mut reader: ImageReader<BufReader<fs::File>>) -> ImageResult<DynamicImage> {
348+
let mut limits = Limits::default();
349+
limits.max_alloc = Some(1024 * 1024 * 1024);
350+
reader.limits(limits.clone());
351+
352+
let mut decoder = reader.into_decoder()?;
353+
let orientation = decoder.orientation()?;
354+
355+
limits.reserve(decoder.total_bytes())?;
356+
decoder.set_limits(limits)?;
357+
358+
let mut image = DynamicImage::from_decoder(decoder)?;
359+
image.apply_orientation(orientation);
360+
361+
Ok(image)
362+
}
363+
352364
fn current_image(output: &str) -> Option<Source> {
353365
let state = State::state().ok()?;
354366
let mut wallpapers = State::get_entry(&state)

0 commit comments

Comments
 (0)