# Picture from camera is not displayed in view

**URL:** <https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586>\
**Category:** Ionic Native\
**Created:** [December 16, 2017, 8:21pm UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586 "2017-12-16T20:21:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catweazle101](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/catweazle101/32/115865_2.png) [@Catweazle101](https://forum.ionicframework.com/u/Catweazle101)\
**Post date:** [December 16, 2017, 8:21pm UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586/1 "2017-12-16T20:21:18Z")

</div>

Hi,

I’m playing the first time with the ionic native camera.

**UseCase:**

1. The user opens an modal-window (ionic-modal-component). (works!)
2. Then he clicks on the button to take the picture. (works!)
3. Preview picture should be displayed (not working!)

**Problem:**  
The image is not displayed after setting the base64-string to the src-attribute.

**Code:**

- **picture-creator.ts**

```auto
    const options: CameraOptions = {
      quality: 25,
      targetHeight: 500,
      targetWidth: 500,
      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }
    
    this.camera.getPicture(options).then((imageData) => {
      this.onPictureCreated.emit(imageData);
    }, (err) => {
      this.errorMessage = JSON.stringify(err);
    });

```

- **modal-page.ts**

```auto
  onArticlePictureCreated(base64String: string){
    this.previewImage = 'data:image/jpeg;base64,' + base64String;
  }

```

- **modal-page.html**

```auto
<ion-img [src]="previewImage"></ion-img>

```

**remarks**

- I’m testing my mobile app currently with the Ionic DevApp. Maybe it’s a problem of DevApp to display the image?

Every hint is welcome. I guess I did almost everything and I’m running out of ideas.

Regards from Zurich  
Oliver

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [December 16, 2017, 8:25pm UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586/2 "2017-12-16T20:25:59Z")

</div>

There’s a tutorial from Paul Holiday on Udemy about Ionic’s native features… he shows you how to display picture taken from an ionic native camera to html. That’s all I know about it.

---

<div class="post-metadata">

**Author:** ![Catweazle101](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/catweazle101/32/115865_2.png) [@Catweazle101](https://forum.ionicframework.com/u/Catweazle101)\
**Post date:** [December 16, 2017, 10:33pm UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586/3 "2017-12-16T22:33:17Z")

</div>

Hi @jamesharvey

I already had a look at this course at Udemy:

> **[Ionic 2/ Ionic 3 - Build iOS & Android Apps with Angular](https://www.udemy.com/ionic-2-the-practical-guide-to-building-ios-android-apps/)**
>
> Build Native iOS and Android Apps with Angular 2/ Angular 4, Cordova and the Ionic 2 Framework. Build 4 Complete Apps!

But there was just a simple ‘hello world’ example, which of course works 😉  
And I did already everything and more.

But I have to mention, that I only tested my mobile app until now with the Ionic DevApp.  
I never tested it on a real device.

I will test it soon on a real device, to see, whether the problem is only on the DevApp side.

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [December 16, 2017, 10:42pm UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586/4 "2017-12-16T22:42:49Z")

</div>

Hi, that’s not the tutorial I’m talking about.  
This one shows you exactly how to build native camera:

> **[Master Ionic 3 with Ionic Native and Cordova Integrations](https://www.udemy.com/master-ionic-3-with-ionic-native-and-cordova-integrations/)**
>
> Supercharge your Ionic applications with everything from Push Notifications, Camera, Contacts, Fingerprint and much more

he shows how to display picture taken to HTML page too.  
Check Camera section of this course!  
I built a camera based on this course and it works just fine on my smartphone…

---

<div class="post-metadata">

**Author:** ![Catweazle101](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/catweazle101/32/115865_2.png) [@Catweazle101](https://forum.ionicframework.com/u/Catweazle101)\
**Post date:** [December 17, 2017, 12:36am UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586/5 "2017-12-17T00:36:38Z")

</div>

I checked out the video that you mentioned, but it did not show anything new.  
I did everything already what was shown in the video.

The only difference what I saw was, that the instructor coded that camera implementation with async/await  
feature. But I think this is not relevant.

So my problem is still unsolved :-/

Cheers,  
Oliver

---

<div class="post-metadata">

**Author:** ![Catweazle101](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/catweazle101/32/115865_2.png) [@Catweazle101](https://forum.ionicframework.com/u/Catweazle101)\
**Post date:** [December 17, 2017, 2:18am UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586/6 "2017-12-17T02:18:42Z")

</div>

Finally I got the solution.

I can’t believe it that it took so long time to see it.  
The problem was somewhere totally on an other place.

**The problem was:**

1. the base64String parameter was always ‘undefined’

```auto
 onArticlePictureCreated(base64String: string){
    this.previewImage = 'data:image/jpeg;base64,' + base64String;
  }

```

1. This happenend, because I did not pass the **$event** param within the html view

```auto
<picture-creator (onPictureCreated)="onPictureCreated($event)"></picture-creator>

```

Grrrrrr…

I think I worked to long with React 😄

I still learn Angular.

But it happens so easy to mix different Framework-Syntax at this time… 😡

but thanks to everyone, who had a look on it.

regards,  
Oliver

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:59pm UTC](https://forum.ionicframework.com/t/picture-from-camera-is-not-displayed-in-view/115586/7 "2021-07-19T21:59:07Z")

</div>

Closed on July 19, 2021, 9:59pm UTC


