You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(computer-vision)!: TextToImage returns file URI instead of base64 (#1180)
## Description
Closes#888.
Moves PNG encoding for `TextToImage` from JS (`pngjs`) into the native
side via the existing `image_processing::saveToTempFile` helper,
mirroring how `StyleTransfer`'s `url` output mode already works.
`TextToImageModule.forward` (and the `useTextToImage` `generate` hook)
now resolves to a `file://` URI pointing to a PNG on disk instead of a
base64-encoded payload.
Also tightens the `StyleTransferModule.forward` JSDoc to document the
`'pixelData'` / `'url'` output modes — that was the doc-correction half
of #888.
The `pngjs` dependency is no longer needed and is dropped from
`packages/react-native-executorch/package.json` and the
`apps/computer-vision` example.
### Introduces a breaking change?
- [x] Yes
- [ ] No
`TextToImageModule.forward` / `useTextToImage.generate` now resolves to
a `file://` URI instead of a base64-encoded PNG string. Callers should
switch from `data:image/png;base64,\${image}` to using the URI directly:
```tsx
<Image source={{ uri: image }} />
```
### Type of change
- [x] Bug fix (change which fixes an issue)
- [ ] New feature (change which adds functionality)
- [x] Documentation update (improves or adds clarity to existing
documentation)
- [ ] Other (chores, tests, code style improvements etc.)
### Tested on
- [ ] iOS
- [x] Android
### Testing instructions
- Run the computer-vision example app -> Text to Image screen, generate
an image with each supported model. Image should render correctly from
the returned URI.
- Verify interrupt still works mid-generation (returned URI string is
empty).
- Verify Style Transfer's `forward(..., 'url')` mode still returns a
`file://` URI (no behavior change, doc-only).
### Screenshots
<!-- Add screenshots here, if applicable -->
### Related issues
Closes#888
### Checklist
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have updated the documentation accordingly
- [x] My changes generate no new warnings
### Additional notes
The C++ integration tests covering `generate` are still `GTEST_SKIP`-ed
pending the existing UNet emulator issue, but I refreshed them so they
exercise the new URI return shape when re-enabled.
* @param [imageSize] - Optional. The target width and height of the generated image (e.g., 512 for 512x512). Defaults to the model's standard size if omitted.
82
82
* @param [numSteps] - Optional. The number of denoising steps for the diffusion process. More steps generally yield higher quality at the cost of generation time.
83
83
* @param [seed] - Optional. A random seed for reproducible generation. Should be a positive integer.
84
-
* @returns A Promise that resolves to a string representing the generated image (e.g., base64 string or file URI).
84
+
* @returns A Promise that resolves to a `file://` URI pointing to the generated PNG on the device, or an empty string if generation was interrupted.
85
85
* @throws {RnExecutorchError} If the model is not loaded or is currently generating another image.
0 commit comments