Skip to content

Apply Exif orientation when decoding a wallpaper - #142

Merged
mmstick merged 1 commit into
pop-os:masterfrom
LeandroPG19:exif-orientation
Jul 23, 2026
Merged

Apply Exif orientation when decoding a wallpaper#142
mmstick merged 1 commit into
pop-os:masterfrom
LeandroPG19:exif-orientation

Conversation

@LeandroPG19

Copy link
Copy Markdown
Contributor

Photos taken in portrait are drawn rotated. Cameras store the pixels laid out
landscape and record the rotation in the Exif metadata, and ImageReader::decode
ignores it. It is also why the same photo looks right in an image viewer but
rotated in the wallpaper and in the cosmic-settings preview.

Decoding through into_decoder gives access to the orientation the decoder
reports, so it can be applied to the decoded image. into_decoder does not
check the allocation limit against the size of the decoded image the way
decode does, so that check is kept explicitly.

Fixes #135

Tested with the 8 Exif orientation values, with images that carry no Exif
metadata (unchanged), and with the wallpapers in /usr/share/backgrounds, which
decode byte for byte identically.

  • I have disclosed use of any AI generated code in my commit messages.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

Comment thread src/wallpaper.rs Outdated
Cameras store portrait photos with the pixels laid out landscape and record
the rotation in the Exif metadata. `ImageReader::decode` ignores it, so those
wallpapers are drawn rotated. It is also why such a photo looks right in an
image viewer but rotated in the wallpaper and in the cosmic-settings preview.

Decode through `into_decoder` instead, so the orientation reported by the
decoder can be applied to the decoded image. Unlike `decode`, `into_decoder`
does not check the allocation limit against the size of the decoded image, so
that check is kept explicitly.

Fixes pop-os#135

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Leandro Pérez G. <leandropatodo@gmail.com>
@mmstick
mmstick requested a review from a team July 13, 2026 16:08
@mmstick

mmstick commented Jul 13, 2026

Copy link
Copy Markdown
Member

Similar changes will be needed for cosmic-settings for cosmic-greeter

@mmstick
mmstick merged commit 76e89e6 into pop-os:master Jul 23, 2026
8 of 9 checks passed
mmstick pushed a commit to pop-os/cosmic-settings that referenced this pull request Jul 24, 2026
Same fix as pop-os/cosmic-bg#142, which was asked for there.

`open_image` has two decoding paths, and neither applies the Exif
orientation:
`ImageReader::decode` for the common formats, and
`DynamicImage::from_decoder` in
`decode_jpegxl`. Cameras store portrait photos with the pixels laid out
landscape
and record the rotation in the Exif metadata, so such a photo is shown
rotated in
the wallpaper page, both in the preview and in the thumbnails.

Both paths now read the orientation from the decoder and apply it to the
decoded
image. `into_decoder` does not check the allocation limit against the
size of the
decoded image the way `decode` does, so that check is kept explicitly.

Tested with the 8 Exif orientation values, with images that carry no
Exif metadata
(unchanged), and with the JPEG XL wallpapers from gnome-backgrounds,
which decode
identically.

cosmic-greeter needs a different change: it does not decode images
itself. It
passes the raw file bytes to `widget::image::Handle::from_bytes`
(src/common.rs),
and those are decoded by `iced_graphics` with `image::load_from_memory`,
which
does not apply the orientation either. So the orientation has to be
applied before
the handle is built, or in the toolkit.

- [x] I have disclosed use of any AI generated code in my commit
messages.
- [x] I understand these changes in full and will be able to respond to
review comments.
- [x] My change is accurately described in the commit message.
- [x] My contribution is tested and working as described.
- [x] I have read the [Developer Certificate of
Origin](https://developercertificate.org/) and certify my contribution
under its conditions.

Signed-off-by: Leandro Pérez G. <leandropatodo@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Softer added a commit to Lin-WMDE/wmde-bg that referenced this pull request Jul 30, 2026
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.
krakotay pushed a commit to krakotay/cosmic-settings that referenced this pull request Aug 10, 2026
Same fix as pop-os/cosmic-bg#142, which was asked for there.

`open_image` has two decoding paths, and neither applies the Exif
orientation:
`ImageReader::decode` for the common formats, and
`DynamicImage::from_decoder` in
`decode_jpegxl`. Cameras store portrait photos with the pixels laid out
landscape
and record the rotation in the Exif metadata, so such a photo is shown
rotated in
the wallpaper page, both in the preview and in the thumbnails.

Both paths now read the orientation from the decoder and apply it to the
decoded
image. `into_decoder` does not check the allocation limit against the
size of the
decoded image the way `decode` does, so that check is kept explicitly.

Tested with the 8 Exif orientation values, with images that carry no
Exif metadata
(unchanged), and with the JPEG XL wallpapers from gnome-backgrounds,
which decode
identically.

cosmic-greeter needs a different change: it does not decode images
itself. It
passes the raw file bytes to `widget::image::Handle::from_bytes`
(src/common.rs),
and those are decoded by `iced_graphics` with `image::load_from_memory`,
which
does not apply the orientation either. So the orientation has to be
applied before
the handle is built, or in the toolkit.

- [x] I have disclosed use of any AI generated code in my commit
messages.
- [x] I understand these changes in full and will be able to respond to
review comments.
- [x] My change is accurately described in the commit message.
- [x] My contribution is tested and working as described.
- [x] I have read the [Developer Certificate of
Origin](https://developercertificate.org/) and certify my contribution
under its conditions.

Signed-off-by: Leandro Pérez G. <leandropatodo@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with vertical wallpapers

3 participants