Saving Captured Photo (templateImage) to Camera Roll

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Saving Captured Photo (templateImage) to Camera Roll

Post by genie » Mon May 19, 2014 5:47 am

Hello!

Good day!

I simply want to capture an image using device's camera and save the photo or email the photo, but I cannot seem to get to control templateImage.
I probably just don't know how to address to it? I tried random things, but somehow stuck.

Code: Select all

on mouseUp
   set the lockloc of the templateimage to true
   set the width of the templateimage to "150"
   set the height of the templateimage to "150"
   set the left of the templateimage to "10"
   set the top of the templateimage to "10"

   // To open native camera
   mobilePickPhoto "camera"

   set the name of the templateImage to "Test"
   create img

   // This one returns "not a supported format", which means the object is not of PNG, GIF of JPEG.
   // How can I make it JPEG anyway?
   put the long ID of image "Test" into tImageID
   mobileExportImageToAlbum tImageID

   // This evaluates to TRUE
   answer exists(img "Test")

   // But this one says "cannot find *"
   mobileExportImageToAlbum img "Test"
end mouseUp
How do I save templateImage()?
Can I send templateImage() as an attachment to an email (in MobileComposeMail)?
How do I copy template image into another image object/control?

Any insights would be greatly appreciated. :)


Regards,
Genie

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by Simon » Mon May 19, 2014 6:19 am

Hi Genie,
Here is how you should be able to email the image (I say should because it doesn't currently work with Android mail LC 6.6.2);

Code: Select all

on mouseUp
      set the vis of the templateImage to false
      mobilePickPhoto "camera"
      put the last image into tAttachment["data"]
      put "image/jpeg" into tAttachment["type"]
      put "cam picture" into tAttachment["name"]
      mobileComposeMail "Camera Example", getRecipient(),,,, tAttachment
end mouseUp
Now since that does work with Android gMail I'd say you don't have to use that "create img" but use "last image" as it will just stick it in there after the mobilePickPhoto .

For the saving I'd use "last image" again but I haven't worked with mobileExportImageToAlbum yet.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by genie » Mon May 19, 2014 7:16 am

Thanks so much, Simon. I will try this out...

Regards,
Genie

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by genie » Mon May 19, 2014 11:46 am

Hi Simon!

This worked well.
Simon wrote:

Code: Select all

on mouseUp
      set the vis of the templateImage to false
      mobilePickPhoto "camera"
      put the last image into tAttachment["data"]
      put "image/jpeg" into tAttachment["type"]
      put "cam picture" into tAttachment["name"]
      mobileComposeMail "Camera Example", getRecipient(),,,, tAttachment
end mouseUp
Was able to place the captured image into an image control by...

Code: Select all

put the last image into image "The_Image"
Was able to save the captured image by...

Code: Select all

mobileExportImageToAlbum tAttachment["data"]
Thank you for your help!


Regards,
Genie

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by genie » Mon May 19, 2014 1:44 pm

One more thing, is there a way to do the same thing for video (instead of photo)?
i.e., capture video, save video, mail video.

There's revRecordVideo but does not work for mobile (only desktop).

I saw that Monte has mergAV, so I guess I can conclude that it is not doable by Livecode alone because an external has been developed. (?)


Thanks,
Genie

luchman
Posts: 3
Joined: Mon Oct 20, 2014 10:57 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by luchman » Mon Oct 20, 2014 11:11 am

Got a problem on android. I can snap and also save the photo in the Pictures folder using the script by Simon. I can also email it. But, cannot open it like other images that are already present in the Pictures folder although can see the thumbnail as usual. "Application unavailable" message pops up when tapped on the thumbnail. The image not showing up in the gallery app either.

But when I download the image from the email and save it, it shows up in the gallery app and opens as usual. The image format is .jpg.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by Simon » Mon Oct 20, 2014 1:28 pm

Hi luchman,

Welcome to the forum :)


Now for the ritual... you have to place your underwear on your head to read this.
OK I lied :)
put "cam picture" into tAttachment["name"]
The next thing I'd try is put "campicture.jpg" into tAttachment["name"]
Note no spaces and an extension.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

luchman
Posts: 3
Joined: Mon Oct 20, 2014 10:57 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by luchman » Mon Oct 20, 2014 2:03 pm

What this answer got to do with mobileExportImageToAlbum which is used to save the image on the phone?
Simon wrote:Hi luchman,

Welcome to the forum :)


Now for the ritual... you have to place your underwear on your head to read this.
OK I lied :)
put "cam picture" into tAttachment["name"]
The next thing I'd try is put "campicture.jpg" into tAttachment["name"]
Note no spaces and an extension.

Simon

luchman
Posts: 3
Joined: Mon Oct 20, 2014 10:57 am

Re: Saving Captured Photo (templateImage) to Camera Roll

Post by luchman » Mon Oct 20, 2014 2:47 pm

Seems like mobileExportImageToAlbum adds an extra space after .jpg of the filename. This makes the file not recognizable by the gallery app. It's fine when I manually remove the space by renaming it. I use Moto G.

Post Reply