I know that I can use "startCamera" to take a photo.
I want to know immediately the number of bytes of the photo (before saving it), for example, 63278 bytes.
How to do this?
Thank you for your hint !!!
I know that I can use "startCamera" to take a photo.
I want to know immediately the number of bytes of the photo (before saving it), for example, 63278 bytes.
How to do this?
Thank you for your hint !!!
Hi,
Behind the scenes, startCamera starts camera uses media management API to check new images, which were taken in time between startCamera call and user exiting camera app.
So Images are already stored, before startCamera call returns.
Afterwards you can use media management API to check file info.
http://www.developer.nokia.com/Resou...anagement.html
See FileSize in table "Returned media information"
http://www.developer.nokia.com/Resou...getlist-2.html
Br,
Ilkka
Using the following codes, my WRT app can take a photo. very good!
My problem is: how to immediately obtain the number of bytes of the taken photo? for example, 69703 bytes. What command/method/property should I use?
Thank you very much for your helpful hint !!!
------------------------------------------------------
function onFail(err)
{ alert("failed"); }
function onSuccess(pic_array)
{ alert("successful");
// how to obtain the number of bytes of the taken photo??? }
var so = nokia.device.load("camera");
var ret = so.startCamera(onSuccess, onFail);
Hi,
In the previous post I encouraged to take look into Platform Services Media Management API. However there is even simpler solution available.
This on requires adding one line to platformservices.js library.
Open platformservices.js and goto line 3850. You should see something like below there.
Then just add _246.size = item.FileSize as a last item.Code:var _246={}; _246.height=item.XPixels; _246.width=item.YPixels; _246.type=item.MimeType; //added _246.size = item.FileSize
After this change, you can access the size data in camera onSuccess callback.
Br,Code:var formatData = picture_array[i].format; var data = "Mime: " + formatData.type + "\nWidth: " + formatData.width + "\nHeight: " + formatData.height+"Size"+ formatData.size;
Ilkka
Thank you, isalento! This is what I need!
Unfortunately, when I run this code, I see:
successful
total: 0
but I don't see:
size: ??????
Can you kindly tell me why? Thank you again!
----------------------------------------------------
function onSuccess(pic_array)
{ var formatData, sizedata;
var total = pic_array.length;
alert("successful");
alert("total: " + total + "");
for (var i = 0; i < total; i++)
{ formatData = pic_array[i].format;
sizedata = "size: " + formatData.size;
alert(sizedata); } }
Did you add "_246.size = item.FileSize" to platformservices.js?
-Ilkka
Does it work now?
If total is zero ( pic_array.length == 0) then camera api didn't find any images that were taken between starting the camera and user exiting camera app.
In other words user didn't press shutter button, before closing the camera app.
Br,
Ilkka
thank you, isalento.
this code doesn't work in both anna and belle.
do you have other solution?
-----------------------
i took 12 photos. they are saved in a sdcard directory (e:/dcim/100nokia/), file name are: 2012-02-20-001.jpg to 2012-02-20-012.jpg
i want to obtain the filesize of the last file. how do i do?
Last edited by bg1fpx; 2012-02-20 at 13:49.
Well that is strange. It works for me in Belle.
Could you share your current code so I could take a closer look? (You can PM me the download url, if you wish)
Br,
Ilkka
thank you for your help, isalento.
download url: http://zh87209461.googlecode.com/files/takephoto.zip
Hi,
Ok now I know why this is failing. It must be the old issue about localized time stamps, that I almost forget.
In platformservices.js var d=new Date(Date.parse(item.FileDate)); line fails, because item.FileDate cannot be parsed to date, unless phone language is set to English.
So to fix it, one should implement custom parsing function for the language of device in use.
Br,
Ilkka
When I change the default language from "Chinese" to "English", everything is good.
But, my users are Chinese, their default language is Chinese.
What do I do for this circumstance?