Repository navigation
Support JPEG encoding of alpha images on GTK - #4798
Merged
Merged
Conversation
freakboy3742
approved these changes
Nov 11, 2026
freakboy3742
left a comment
Member
There was a problem hiding this comment.
Good catch - I've pushed a couple of cleanups, but otherwise this looks great!
Comment on lines
+43
to
+44
| - On GTK, saving an image as JPEG discards its alpha channel; the original image retains its transparency. | ||
|
|
Member
There was a problem hiding this comment.
This doesn't require a note.
Suggested change
| - On GTK, saving an image as JPEG discards its alpha channel; the original image retains its transparency. |
| @@ -0,0 +1 @@ | |||
| Images with an alpha channel could be saved as JPEG files with newer GTK image encoders. | |||
Member
There was a problem hiding this comment.
The tense of this change note is wrong:
Suggested change
| Images with an alpha channel could be saved as JPEG files with newer GTK image encoders. | |
| On GTK, images with an alpha channel can now be saved as JPEG when GdkPixbuf uses Glycin-based encoders. |
| rgb[y * width * 3 + channel : (y + 1) * width * 3 : 3] = row[ | ||
| channel::4 | ||
| ] | ||
| native = GdkPixbuf.Pixbuf.new_from_bytes( |
Member
There was a problem hiding this comment.
This works, but it's involves direct memory manipulation, which makes me nervous. I'm pretty sure this can be solved with GTK's existing image compositor, mixing the RGBA source image onto a "blank" RGB image, and then saving the composite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert GTK images with an alpha channel to RGB before JPEG encoding. Newer GdkPixbuf/Glycin encoders reject RGBA input for JPEG; the conversion preserves RGB values and leaves the source image unchanged. The image-save test now exercises both RGB and RGBA sources.
Found while validating the GTK4 migration in #3069.
Validation: 9 image testbed tests passed on GTK3, GTK4, GTK4/libadwaita, and macOS. Pre-commit, docs lint, and core/Travertino tests passed with 100% coverage.
PR Checklist:
Assisted-by: OpenAI Codex (GPT-6)