Skip to content

Compress images and videos before upload - #6429

Open
mahibi wants to merge 1 commit into
masterfrom
feature/5190/imageCompression
Open

Compress images and videos before upload#6429
mahibi wants to merge 1 commit into
masterfrom
feature/5190/imageCompression

Conversation

@mahibi

@mahibi mahibi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Adds an optional compression step to the chat attachment upload flow, covering both gallery-picked and camera-captured photos/videos.

  • Add ImageCompressor/VideoCompressor utilities: images are downscaled and re-encoded as JPEG; videos are downscaled to 540p short side and transcoded via Media3 Transformer on a dedicated HandlerThread so the main thread is never blocked.
  • Migrate the file attachment preview dialog to Jetpack Compose, adding thumbnails, per-file dimensions/size preview, and a "Compress images and videos" checkbox that updates the preview live.
  • Persist the compression choice as a user preference (default on), with a toggle in Settings.
  • Extend the existing upload notification to also show live progress ("Compressing… X%") while a video is being transcoded, by polling Transformer.getProgress(), before it turns into the upload progress notification.
    • --> this is just a temporary solution until in chat upload previews are implemented.
  • Modernize BitmapShrinker to use ImageDecoder on API 28+ (single-pass decode+scale, automatic EXIF rotation for JPEG/HEIC), falling back to the previous BitmapFactory-based path on API 26/27.
  • Fix MIME-type resolution for file:// URIs (e.g. camera-captured photos/videos), which previously failed dialog/thumbnail detection since ContentResolver.getType() only handles content:// URIs.

Assisted-by: Claude Code 2.1.199:claude-sonnet-5

🖼️ Screenshots

grafik grafik grafik

🚧 TODO

  • ...

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@mahibi mahibi self-assigned this Jul 28, 2026
@mahibi
mahibi requested a review from rapterjet2004 July 28, 2026 18:36
@mahibi mahibi added the 3. to review Waiting for reviews label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30387637532/artifacts/8699821637
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

Adds an optional compression step to the chat attachment upload flow,
covering both gallery-picked and camera-captured photos/videos.

  - Add ImageCompressor/VideoCompressor utilities: images are downscaled
    and re-encoded as JPEG; videos are downscaled to 540p short side and
    transcoded via Media3 Transformer on a dedicated HandlerThread so the
    main thread is never blocked.
  - Migrate the file attachment preview dialog to Jetpack Compose, adding
    thumbnails, per-file dimensions/size preview, and a "Compress images
    and videos" checkbox that updates the preview live.
  - Persist the compression choice as a user preference (default on),
    with a toggle in Settings.
  - Extend the existing upload notification to also show live progress
    ("Compressing… X%") while a video is being transcoded, by polling
    Transformer.getProgress(), before it turns into the upload progress
    notification.
  - Modernize BitmapShrinker to use ImageDecoder on API 28+ (single-pass
    decode+scale, automatic EXIF rotation for JPEG/HEIC), falling back to
    the previous BitmapFactory-based path on API 26/27.
  - Fix MIME-type resolution for file:// URIs (e.g. camera-captured
    photos/videos), which previously failed dialog/thumbnail detection
    since ContentResolver.getType() only handles content:// URIs.

Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from cd7df8f to c950080 Compare July 28, 2026 18:44
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30388822788/artifacts/8700239068
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

)
.build()

mNotifyManager!!.notify(notificationId, compressionNotification)

@jancborchardt jancborchardt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be nice to formulate and design it a bit less technical. Signal e.g. specifically calls it "Sent media quality" with an easy to understand "Low" and "High" setting.

I'd say we could have a single-select segmented button in the send flow with:

  • Original quality
  • Reduced quality

And last selected setting remembered. What do you think @nimishavijay

@mahibi

mahibi commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

For reference: thats how signal does it in the send flow (in the left pic it is the (crossed) HD button):

grafik grafik

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

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use compression for images and files selected via gallery

3 participants