nstudio / nstudio/nativescript-plugins
[nativescript-camera-plus][ios] - wrong format of file when photo is taken.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 55
- Forks
- 42
- Avg merge
- 49m
- Merged PRs (30d)
- 1
Description
I ran into an issue when I was using the plugin on iOS. When the picture was taken and I tried to save it to a folder, I got an error saying: error Error: -[DictionaryAdapter _rasterizedImage]: unrecognized selector sent to instance 0x283f1ea90
The code I'm using:
const imageFolder = knownFolders.documents();
console.log('event-data', event.data);
const iosImage = UIImageJPEGRepresentation(event.data, 0.7);
const result1 = NSFileManager.defaultManager.createFileAtPathContentsAttributes(imageFolder.path + "/cam_capture.jpg", iosImage, null);
So I had to change the file index.ios.js to the following:
import { Color, isAndroid, Device, File, ImageAsset, knownFolders, path, Utils, View } from '@nativescript/core';
(import isAndroid)
Then, in the savePhoto function I changed the const handleSuccess function to this:
const handleSuccess = () => {
if (!isAndroid) {
this._owner.get().sendEvent(CameraPlus.photoCapturedEvent, this._photoToSave);
} else {
this._owner.get().sendEvent(CameraPlus.photoCapturedEvent, asset);
}
this.resetPreview();
};
This gets rid of the error.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the plugin's index.ios.js file and inspect savePhoto, especially the handleSuccess callback and the values sent with CameraPlus.photoCapturedEvent. Reproduce the iOS photo-save flow using UIImageJPEGRepresentation and NSFileManager, then verify that the emitted photo can be saved without the DictionaryAdapter _rasterizedImage error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, typescript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100