Skip to content

fix(ios): convert gallery HEIC/HEIF to JPEG for WebView compatibility#7

Open
shreejanpandit wants to merge 1 commit into
NativePHP:mainfrom
shreejanpandit:fix/ios-gallery-heic-to-jpeg
Open

fix(ios): convert gallery HEIC/HEIF to JPEG for WebView compatibility#7
shreejanpandit wants to merge 1 commit into
NativePHP:mainfrom
shreejanpandit:fix/ios-gallery-heic-to-jpeg

Conversation

@shreejanpandit
Copy link
Copy Markdown

Problem

On iOS, camera capture saves photos as JPEG, and the README states “JPEG for photos”.

The gallery picker copies files as-is via loadFileRepresentation. On iPhone that is often HEIC/HEIF. Those files are valid on disk, but WKWebView cannot display HEIC in <img>, so profile/media previews in Livewire, Blade, or Inertia fail even when upload still works.

Camera and gallery therefore behave differently within the same plugin.

Solution

In copyFileToCache, after copying to cache:

  • If the image extension is heic or heif, convert to JPEG with jpegData(compressionQuality: 0.9) (same as camera capture).
  • Return .jpg path and image/jpeg mime type.
  • JPEG, PNG, GIF, WebP, and video are unchanged — same flow as today.

~35 lines in resources/ios/CameraFunctions.swift only. No change to processPickerResults or event payload shape.

Why this is needed

  • Aligns gallery behavior with documented photo format and existing camera JPEG handling.
  • Fixes a common NativePHP Mobile use case: showing a gallery image in the WebView before upload.
  • Minimal and safe — only HEIC/HEIF are converted; other formats are not altered.

@shreejanpandit shreejanpandit marked this pull request as draft June 1, 2026 10:15
Gallery picker copied HEIC as-is while camera capture already saves JPEG.
WKWebView cannot display HEIC in img elements. Convert only heic/heif
extensions after copy; other formats unchanged.
@shreejanpandit shreejanpandit force-pushed the fix/ios-gallery-heic-to-jpeg branch from 9bde901 to d55c6ed Compare June 1, 2026 10:17
@shreejanpandit shreejanpandit marked this pull request as ready for review June 1, 2026 10:18
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.

1 participant