O$ Take Photo using iPad camera with jsDevice

Phil Phil at pgpotter.co.uk
Fri May 8 04:36:50 EDT 2020


Hi Michael,

As Thad mentions, the devices take jpeg photos, and since there is a 
jpeg object that you can place on a thick client window, we don't change 
that.

We use the sync server, and so our pictures remain in the database, this 
is the only way it can work on the device when it is not connected to 
the internet.

So, this means a subset of the data is on the phone so that it can work 
when offline, meaning it needs the photo in the data, and when it comes 
back online, it syncs with the sync server, and new photos etc. transfer 
to tables on the main database...

We use postgres for the main database, and the photo is in a bytea field.
On the devices, by default, it uses sqlite, with the schema identified 
as binary.

regards
Phil.

On 08/05/2020 05:26, Thad Bogert wrote:
> Hi Michael,
>
> The Device Control returns a jpeg image.  To use the image on the javascript form you need to use a binary variable as the $dataname for both the Device and the Picture control.  The $mediatype property of the image control should be: image/jpeg
>
> If you wish to convert the image to an Omnis picture format for use elsewhere you would need to use the one of the picture conversion functions.
>
> As a side note, while it’s is convenient to store images in a database, it creates the possibility that the database file will grow very quickly.  I may be mistaken, but I believe the CS32 pictures are uncompressed bitmaps.  It also creates additional overhead for the database/dam to fetch the image data from the database into studio.  And with he JS client, the data also has to passed from Omnis to the client.
>
> An approach that we use in our application is to save all images as JPEGs (to save space) to the file system and then store the filename in the database.  In the case of the desktop clients, the files are on a shared volume with the directory path stored as a preference.  It then becomes a matter of either using fileops to read the file into the runtime and display it in the picture control.  Or using the JPEG control you can assign filepath of the image the the $path property.
>
> With the JS client, we create a virtual directory on the web server that points to the same shared location.  A URL to the image can then be constructed and passed to the picture control via character variable assigned to its $dataname property.  The advantage of this approach is that the loading of the image is managed the web server and the web browser that is rendering the JS form; which frees up Studio and the web client to do other things.
>
>
>
>
>
>> On May 7, 2020, at 7:19 PM, Michael Houlberg <michael at houlbergdevelopment.com> wrote:
>>
>> Phil,
>>
>> Maybe you know something about this.  My original post was shortened because I clicked Send prematurely.
>>
>> I have both a desktop app and a javascript app accessing the same SQLite database.  The image is stored in the database defined with a datatype as “Picture” in Omnis.  This works best with a kPictureObj on the window class.  What’s nice is I can paste in any kind of image, jpeg, png, etc, and it gets stored as CS32.
>>
>> Now on the javascript form, I have a Picture Control jsPict and set the dataname to the correct column in the list.  The code to load the list runs on the server, when I look at the variable, I can see the image.  But on the form, there is nothing.  I have set the $dataname, but the $mediatype might be the problem.  I’ve tried leaving it blank, or “image/CS32” or just “CS32”.  Do you have a clue?
>>
>> Thanks,
>> Michael Houlberg
>> Houlberg Development, LLC
>>
>>> On May 7, 2020, at 2:51 AM, Phil (OmnisList) via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
>>>
>>> Hi Michael,
>>>
>>> I believe your problem is that the pictformat procedure does not work on the client.
>>>
>>> You can only do that on the server, or, if you are saving it into sqlite to be synchronised to the main database later, then in the main application when evaluating the synchronised data.
>>>
>>> regards
>>> Phil Potter
>>> Based in Chester in the UK.
>>>
>>> On 06/05/2020 22:13, Michael Houlberg wrote:
>>>> $listers:
>>>>
>>>> I have an iPad-wrapped application that I want to grab a picture with the built in camera.  I’m using the Device Control JavaScript Component.  I can name the variable to be the target of the camera in the $deviceimage property.  I have an instance var named ivDeviceImage named here.
>>>>
>>>> It starts off pretty easy.  A push button on the form has something like this:
>>>>
>>>> Do $cinst.$objs.Device.$action.$assign(kJSDeviceActionTakePhoto)
>>>>
>>>> That activates the camera, takes a picture, gives me the options to “Retake" or “Use Photo”.  When I tap “Use Photo”, the Device Control on my form receives the event ivPhotoReturned and my variable ivDeviceImage contains data.  So in the $event method I include:
>>>>
>>>> On evPhotoReturned
>>>>
>>>> I’ve tried to assign this to a picture field on the form:
>>>> Calculate ivImage as ivDeviceImage
>>>>
>>>> Calculate lFormat as pictformat(ivDeviceImage)
>>>>
>>>>
>>>> _____________________________________________________________
>>>> Manage your list subscriptions at http://lists.omnis-dev.com
>>>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>>> _____________________________________________________________
>>> Manage your list subscriptions at http://lists.omnis-dev.com
>>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

-- 

P G Potter, 11 Regency Court, Mickle Trafford, Chester, UK.

This message is confidential and intended for the use only of the person 
to whom it is addressed. If you are not the intended recipient you are 
strictly prohibited from reading, disseminating, copying, printing, 
re-transmitting or using this message or its contents in any way. 
Opinions, conclusions and other information expressed in this message 
are not given or authorised by the Company unless otherwise indicated by 
an authorised representative independent of this message. The Company 
does not accept liability for any data corruption, interception or 
amendment to any e-mail or the consequences thereof. Emails addressed to 
individuals may not necessarily be read by that person unless they are 
in the office.




More information about the omnisdev-en mailing list