Skip to content

Commit 667ca48

Browse files
authored
Document Android image_format (WebP) for Mobile 4.6 (#554)
1 parent dd497db commit 667ca48

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎resources/views/docs/mobile/4/the-basics/app-icon.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Place a single high-resolution icon file at: `public/icon.png`.
1818
This image will be automatically resized for all Android densities and used as the base iOS app icon.
1919
You must have the GD extension installed in your development machine's PHP environment for this to work.
2020

21+
On Android, the resized icons can be written as WebP instead of PNG to reduce your app's size. See
22+
[Android Image Format](splash-screens#android-image-format).
23+
2124
<aside>
2225

2326
If you do not provide a custom app icon, a default one will be used.

‎resources/views/docs/mobile/4/the-basics/splash-screens.md‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,46 @@ Place the relevant files in the locations specified:
1313
- `public/splash-dark.png` - for the Dark Mode splash screen
1414

1515
### Requirements
16-
- Format: PNG
16+
- Format: PNG (WebP is also accepted on Android, see below)
1717
- Minimum Size/Ratio: 1080 × 1920 pixels
1818
- GD PHP extension must be enabled, ensure it has enough memory (~2GB should be enough)
19+
20+
## Android Image Format
21+
22+
<x-docs.version-badge since="4.6" />
23+
24+
When building for Android, NativePHP resizes your splash screens (and [app icon](app-icon)) into a bitmap for every
25+
screen density. By default these are written as PNG files.
26+
27+
Full-screen splash images are large, and multiplied across five densities and two themes they can add tens of
28+
megabytes to your app bundle. Google Play Console flags this under "Optimize your app's images".
29+
30+
To ship smaller files, set the `image_format` option under the `android` key in `config/nativephp.php` to `webp`:
31+
32+
```php
33+
'android' => [
34+
'image_format' => env('NATIVEPHP_ANDROID_IMAGE_FORMAT', 'png'),
35+
],
36+
```
37+
38+
```dotenv
39+
NATIVEPHP_ANDROID_IMAGE_FORMAT=webp
40+
```
41+
42+
- `png` - Default. Compressed PNG files.
43+
- `webp` - Lossless WebP files. Same visual output, usually 80-90% smaller than PNG.
44+
45+
When switching formats, the files from the previous format are removed on the next build, so you won't get
46+
duplicate resource errors.
47+
48+
You may also supply `public/splash.webp` and `public/splash-dark.webp` as sources for Android. When both a `.webp`
49+
and a `.png` exist, the `.webp` is used.
50+
51+
<aside>
52+
53+
WebP output requires your PHP GD extension to be compiled with WebP support. If it isn't, NativePHP falls back to
54+
PNG output instead of failing the build. You can check with `php -r "var_dump(function_exists('imagewebp'));"`.
55+
56+
iOS always uses the PNG files, so keep `public/splash.png` and `public/splash-dark.png` if you build for iOS.
57+
58+
</aside>

0 commit comments

Comments
 (0)