Skip to content

feat: allow providing background color when transforming images with alpha channel to a format without it - #3800

Merged
szuperaz merged 9 commits into
developfrom
image-background-for-png-webp-conversion
Sep 15, 2026
Merged

szuperaz merged 9 commits into
developfrom
image-background-for-png-webp-conversion

Conversation

@szuperaz

@szuperaz szuperaz commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🎯 Goal

Feature request: https://getstream.slack.com/archives/C02GBL5M1BK/p1788176084433019

The problem:

  • When transforming images with an alpha channel (PNG/Webp) to a format without an alpha channel (for example JPEG) the resulting image's background is platform-dependent: black on Android, white on iOS 26
  • The request: provide an option for integrators to specify an explicit background color for these transforms

How to use it?

const localCompressImage = defaultNativeHandlers.compressImage;

registerNativeHandlers({
  compressImage: localCompressImage
    ? (params) => localCompressImage({ ...params, backgroundColor: '#FFFFFF' })
    : undefined,
});

🛠 Implementation details

Works for CLI-only because expo-image-manipulator doesn't have such option. The default background color is white.

🎨 UI Changes

iOS
Before After
Android
Before After

🧪 Testing

☑️ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

@Stream-SDK-Bot

Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 2031 KB 2031 KB 0 B 🟢

@szuperaz szuperaz changed the title Image background for png webp conversion feat: allow providing background color when transforming images with alpha channel to a format without it Sep 10, 2026
Comment thread package/native-package/types/index.d.ts
@szuperaz
szuperaz marked this pull request as ready for review September 11, 2026 14:37

@isekovanic isekovanic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the couple of comments, looks good, thank you !

I'm wondering if we should add some default background color but I guess that's breaking, so we have to sort of stick to what we have currently I believe.

Comment thread package/native-package/src/native/index.tsx
Comment thread package/native-package/types/index.d.ts
Comment thread package/native-package/src/native/types.ts Outdated
@szuperaz
szuperaz merged commit 1d46a53 into develop Sep 15, 2026
11 checks passed
@szuperaz
szuperaz deleted the image-background-for-png-webp-conversion branch September 15, 2026 12:12
@github-actions github-actions Bot mentioned this pull request Sep 15, 2026
6 tasks
@stream-ci-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 9.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants