×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    How to obtain the number of bytes of a photo taken by "startCamera"

    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 !!!

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    thank you, isalento, i will carefully see these pages.

  4. #4
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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);

  5. #5
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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.

    Code:
    var _246={};
    _246.height=item.XPixels;
    _246.width=item.YPixels;
    _246.type=item.MimeType;
    //added
    _246.size = item.FileSize
    Then just add _246.size = item.FileSize as a last item.

    After this change, you can access the size data in camera onSuccess callback.
    Code:
    var formatData = picture_array[i].format;		
    var data = "Mime: " + formatData.type + "\nWidth: " + formatData.width + "\nHeight: " + formatData.height+"Size"+ formatData.size;
    Br,
    Ilkka

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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); } }

  7. #7
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    Did you add "_246.size = item.FileSize" to platformservices.js?

    -Ilkka

  8. #8
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    YES!!! Added!!!

  9. #9
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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

  10. #10
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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.

  11. #11
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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

  12. #12
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    thank you for your help, isalento.

    download url: http://zh87209461.googlecode.com/files/takephoto.zip

  13. #13
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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

  14. #14
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    ..........
    Last edited by bg1fpx; 2012-02-21 at 10:19.

  15. #15
    Registered User
    Join Date
    Jan 2012
    Posts
    28

    Re: How to obtain the number of bytes of a photo taken by "startCamera"

    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?

Similar Threads

  1. Replies: 0
    Last Post: 2008-02-27, 02:16
  2. send sms from a "TEXT" and not a "NUMBER"
    By cha0s4u in forum General Messaging
    Replies: 6
    Last Post: 2007-01-18, 04:27
  3. Replies: 2
    Last Post: 2006-10-04, 15:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×