nstudio / nstudio/nativescript-plugins

[nativescript-camera-plus][ios] - wrong format of file when photo is taken.

Open
#146 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.