Temporary jpg files when capturing photo

83 views
Skip to first unread message

Mario Barón

unread,
Oct 2, 2013, 5:06:48 PM10/2/13
to codenameone...@googlegroups.com
Hey guys,


I am working on an Android app that involves capturing a camera photo, I've been working with it perfectly but I just noticed it's been creating temporary .jpg files when I capture it. Can you please tell me where I'm going wrong?

My photo capturing method goes like this:

public Image capturarFoto(int ancho, int alto) {
    String imagen = Capture.capturePhoto();
    Image img = null;
    try {
      if (imagen != null) {
        img = Image.createImage(imagen);
        img=img.scaled(ancho, alto);
      }
    } catch (IOException e) {
     
      System.err.println();
    }
    return img;
  }

Thanks a lot!

Shai Almog

unread,
Oct 3, 2013, 1:53:22 AM10/3/13
to codenameone...@googlegroups.com
The capturePhoto method creates a temporary image by definition, I don't understand the issue?

Mario Barón

unread,
Oct 3, 2013, 8:12:13 AM10/3/13
to codenameone...@googlegroups.com
Hey Shai, 

thanks for your response. The issue with this is that after capturing the photo I just save it on the local sotrage, but when I go to Android's native gallery app and temp.jpg files are being created but don't display any kind of data just gray color. Is there a way to not have this temp files created or what's the correct procedure to follow when I don't want to save pictures to the file system but directly to local storage?

Shai Almog

unread,
Oct 3, 2013, 3:04:47 PM10/3/13
to codenameone...@googlegroups.com
I think Chen is more equipped to answer this than I am. Which device/OS?
Do you have a screenshot for these temp files?

Mario Barón

unread,
Oct 3, 2013, 3:30:02 PM10/3/13
to codenameone...@googlegroups.com
Hey Shai, 

I'm using a Galaxy Note 2 running Android 4.1.1 but this is also happening on another device running Android 4.0.4. The following are a couple of screenshots of the problem. As you can see the device's pictures app contains a bunch of temp files created when I take a picture using the camera and they also have some weird info. The problem isn't really affecting the app, but still this temp files can't really be left hanging there. Jumm.. something I just noticed also is that there are some files being created at the sdCard0/Pictures/App_name folder... this are the image files but with a .jpgs format.

I don't know if this is happening do to the way I'm recovering the image as a byte[], but anyway, I'm doing it like this: 


Image img= capturarFoto(500, 500);
ByteArrayOutputStream out = new ByteArrayOutputStream();

imgIo.save(img), out, ImageIO.FORMAT_JPEG, 1);

byte[] foto = out.toByteArray();
out.close();



public Image capturarFoto(int ancho, int alto) {
    String imagen = Capture.capturePhoto();
    Image img = null;
    try {
      if (imagen != null) {
        img = Image.createImage(imagen);
        img=img.scaled(ancho, alto);
      }
    } catch (IOException e) {
     
      System.err.println();
    }
    return img;
  }

the 500, 500 sizes I pass to it are just arbitrary sizes I put here to demonstrate. 


Thanks a lot for your help. 



On Wednesday, October 2, 2013 4:06:48 PM UTC-5, Mario Barón wrote:
Screenshot_2013-10-03-14-08-09.png
Screenshot_2013-10-03-14-07-45.png

Mario Barón

unread,
Oct 11, 2013, 9:40:56 AM10/11/13
to codenameone...@googlegroups.com
Hey guys, 

sorry to be so insisting but, have any of you guys been able to take a look at this? I'm a little stomped with this, can you please give me a hand? I don't know if what I'm doing is wrong or I'm leaving something out.


I really appreciate your help, thanks.


On Wednesday, October 2, 2013 4:06:48 PM UTC-5, Mario Barón wrote:

Chen Fishbein

unread,
Oct 11, 2013, 3:43:03 PM10/11/13
to codenameone...@googlegroups.com
I am looking into this, will update this post with the an answer

Chen Fishbein

unread,
Oct 13, 2013, 7:11:26 AM10/13/13
to codenameone...@googlegroups.com
I have re-implemented the camera functionality in android. - it suffered from other issues besides the one described here.
The code is already committed to the svn and will be uploaded later(during the week) to the build server.
Thanks for the detailed issue description.

Mario Barón

unread,
Oct 15, 2013, 9:33:31 AM10/15/13
to codenameone...@googlegroups.com
Hey Chen,

thanks a lot for your help. I'll be trying it out this week and telling you the results then.


Keep up the exceptional work guys.
 

On Wednesday, October 2, 2013 4:06:48 PM UTC-5, Mario Barón wrote:
Reply all
Reply to author
Forward
0 new messages