Possible to capture image like an upload file and save in database

Possible to capture image like an upload file and save in database

  

Mobile app to capture an image from the mobile phone's camera and save it like an upload file in a database.


Thank you.

Hi Edwin,

Yes, this is possible. 

Use the Camera plugin and store the binary in the local storage.

Then use the sync functionality to store the binary in the centralized database.

Kind regards,

Remco Dekkinga

Actually no need for Camera plugin.

Just create an entity (can be database or local), that contain an attribute with Binary data type.

In mobile screen, just drag a Form, then drag that attribute to the Form.

Outsystems will scaffolding an upload widget for you.

When running that application, you can click Upload, then phone will ask if you want to upload from Phone Gallery or from Camera.

To save the image binary, in the save button, before calling CreateOrUpdateEntity, assign UploadWidget.binary to your list.current.binaryattribute record variable.

Harlin Setiadarma wrote:

Actually no need for Camera plugin.

Just create an entity (can be database or local), that contain an attribute with Binary data type.

In mobile screen, just drag a Form, then drag that attribute to the Form.

Outsystems will scaffolding an upload widget for you.

When running that application, you can click Upload, then phone will ask if you want to upload from Phone Gallery or from Camera.

To save the image binary, in the save button, before calling CreateOrUpdateEntity, assign UploadWidget.binary to your list.current.binaryattribute record variable.

Mobile Upload does NOT have a "binary" attribute. It binds to the list automatically and updates the binary data there.

J.Ja

Solution

Justin James wrote:

Harlin Setiadarma wrote:

Actually no need for Camera plugin.

Just create an entity (can be database or local), that contain an attribute with Binary data type.

In mobile screen, just drag a Form, then drag that attribute to the Form.

Outsystems will scaffolding an upload widget for you.

When running that application, you can click Upload, then phone will ask if you want to upload from Phone Gallery or from Camera.

To save the image binary, in the save button, before calling CreateOrUpdateEntity, assign UploadWidget.binary to your list.current.binaryattribute record variable.

Mobile Upload does NOT have a "binary" attribute. It binds to the list automatically and updates the binary data there.

J.Ja

Thanks for correcting.

I want to add some notes here:

1. Camera plugin will resize image to small resolution which often produces jagged lines because of simple resize algorithm used.

2. Image upload widget will return original resolution of your phone camera which can be as high as 16 megapixels (or more) which is common nowadays... That will give you time out when sending record to server for database saving.

That's why I developed Image Utils Mobile (can be found in Forge) which can resize on client-side those 16 megapixels image to smaller resolution without sacrificing image quality. It will also correct image orientation which will be useful for some phone like Samsung which does not trully rotate image, but instead put orientation hint on EXIF data. 


Solution

Harlin Setiadarma wrote:

Justin James wrote:

Harlin Setiadarma wrote:

Actually no need for Camera plugin.

Just create an entity (can be database or local), that contain an attribute with Binary data type.

In mobile screen, just drag a Form, then drag that attribute to the Form.

Outsystems will scaffolding an upload widget for you.

When running that application, you can click Upload, then phone will ask if you want to upload from Phone Gallery or from Camera.

To save the image binary, in the save button, before calling CreateOrUpdateEntity, assign UploadWidget.binary to your list.current.binaryattribute record variable.

Mobile Upload does NOT have a "binary" attribute. It binds to the list automatically and updates the binary data there.

J.Ja

Thanks for correcting.

I want to add some notes here:

1. Camera plugin will resize image to small resolution which often produces jagged lines because of simple resize algorithm used.

2. Image upload widget will return original resolution of your phone camera which can be as high as 16 megapixels (or more) which is common nowadays... That will give you time out when sending record to server for database saving.

That's why I developed Image Utils Mobile (can be found in Forge) which can resize on client-side those 16 megapixels image to smaller resolution without sacrificing image quality. It will also correct image orientation which will be useful for some phone like Samsung which does not trully rotate image, but instead put orientation hint on EXIF data. 



Hi Harlin, I have problems with samsung cell phones that when capturing the image with the object upload the image rotates, I am trying to use the fix orientation routine but it is not working, in the orientation parameter I use what? The grade, example 90, 180?

You can get the orientation by using Identify action first.

Then use fix orientation action, with orientation parameter filled by Identify.orientation output which I just noticed have a bug (data type: text, should be integer, so you need texttointeger) which will be fixed soon.



Or you can use Resize function from my Image Utils Mobile, which already correct orientation by default.

In the next version of Image Utils Mobile, I decided to make Fix Orientation autonomous action by removing orientation input parameter and getting orientation automatically.

UPDATE:

I already released new version, now FixOrientation will automatically get EXIF orientation info if input parameter "orientation" is left blank.

If input parameter "orientation" was passed, then FixOrientation action will rotate image based on that parameter.


Download new version: https://www.outsystems.com/forge/2078/

Here's link to Test FixOrientation action: https://harlin.outsystemscloud.com/PreviewInDevices/?IsMobilePreview=True&DeviceName=Smartphone&URL=/fix_orientation (OML attached)