Page 1 of 2 12 LastLast
Results 1 to 20 of 28
  1.    #1  
    I need to allow users to take a photo and then my app uses that photo, but currently all the images taken by the camera are 1.4 MB in size. That's huge and a big memory hog when it's opened/dealt with. How are all of you handling this?
  2. ryang's Avatar
    Posts
    30 Posts
    Global Posts
    42 Global Posts
    #2  
    If you're talking about pictures captured on the Pre and sent to people, you'll have to re-size them on a PC before sending. To date there is no image editing/resizing functionality.
  3.    #3  
    Quote Originally Posted by ryang View Post
    If you're talking about pictures captured on the Pre and sent to people, you'll have to re-size them on a PC before sending. To date there is no image editing/resizing functionality.
    Actually I was talking about using them within an app on the Pre. As far as I can tell, to get the bytes of the image (to allow altering the image), I need to use ajax. This is SUPER slow. Is there any other way?
  4. worthb's Avatar
    Posts
    241 Posts
    Global Posts
    259 Global Posts
    #4  
    Quote Originally Posted by 6tr6tr View Post
    Actually I was talking about using them within an app on the Pre. As far as I can tell, to get the bytes of the image (to allow altering the image), I need to use ajax. This is SUPER slow. Is there any other way?
    Take a look at the webview widget. It allows you to resize images (resizeImage method accepts parameters for input filename, output filename, width and height). You can also load an image into the view (pass a file:// url) and save the view or a cropped section to a file (see saveViewToFile method).

    Webview Widget
    LaunchPoint Speed Dial - There's no faster way to dial, email, or text, period.
  5.    #5  
    Quote Originally Posted by worthb View Post
    Take a look at the webview widget. It allows you to resize images (resizeImage method accepts parameters for input filename, output filename, width and height). You can also load an image into the view (pass a file:// url) and save the view or a cropped section to a file (see saveViewToFile method).

    Webview Widget
    THANKS! I'm going to give that a try and see if it works. I'll post back here with the results.
  6. vvsds's Avatar
    Posts
    18 Posts
    Global Posts
    23 Global Posts
    #6  
    What's the max size of a photo that the pre can accept through an email?
  7. strudel's Avatar
    Posts
    190 Posts
    Global Posts
    192 Global Posts
    #7  
    I have sent and recieved pictures taken from the Pre via email. They take a bit to download sometimes but otherwise everything works fine.
  8. vvsds's Avatar
    Posts
    18 Posts
    Global Posts
    23 Global Posts
    #8  
    I found out what my problem was...my friend would send me pics via mms from her blackberry and I couldn't save em. She would send them to my email, so I told her to send the pics again to my email but via her email instead of mms. And I can save em now. I had thought it was a pic size issue as it not saving the 1st go round
  9.    #9  
    Quote Originally Posted by worthb View Post
    Take a look at the webview widget. It allows you to resize images (resizeImage method accepts parameters for input filename, output filename, width and height). You can also load an image into the view (pass a file:// url) and save the view or a cropped section to a file (see saveViewToFile method).

    Webview Widget
    I have it loading the local image into the webview (for some reason it only works if you setup the widget in the scene's "setup" method, not anywhere else). HOWEVER, it won't save the new file. Perhaps I'm doing something wrong?

    I first tried to do the resizing in the "finished" callback (but it's never called - why?) so then I tried in the stopped callback but it never runs/works:

    Code:
    FirstAssistant.prototype.stopped = function(event) 
    {
    
         //This is called
         Mojo.Log.error( "stopped" ); 
         
         //This fails (but with no error message)
         this.controller.get( "web-view" ).mojo.resizeImage( 
            	"file:///var/usr/palm/applications/com.mystuff.hello/icon.png",
            	"file:///var/usr/palm/applications/com.mystuff.hello/icon2.png",
            	10,
            	10
            );
    
         //This is NEVER called
            Mojo.Log.error( "4" );
    }
  10.    #10  
    I figured it out!

    While the webview creation requires a URL (and thus a "file://" protocol signifier), the resizeImage does not.

    So it's:

    /var/usr/palm/applications/com.mystuff.hello/icon.png",
    /var/usr/palm/applications/com.mystuff.hello/icon2.png"
  11. worthb's Avatar
    Posts
    241 Posts
    Global Posts
    259 Global Posts
    #11  
    Quote Originally Posted by 6tr6tr View Post
    I figured it out!

    While the webview creation requires a URL (and thus a "file://" protocol signifier), the resizeImage does not.

    So it's:

    /var/usr/palm/applications/com.mystuff.hello/icon.png",
    /var/usr/palm/applications/com.mystuff.hello/icon2.png"
    Glad to see you got it working.
    LaunchPoint Speed Dial - There's no faster way to dial, email, or text, period.
  12.    #12  
    Quote Originally Posted by worthb View Post
    Glad to see you got it working.
    Yes, but it's useless for my needs. I really needed it to resize the camera images, but those are JPG's and WebView won't resize jpg's!!
  13. worthb's Avatar
    Posts
    241 Posts
    Global Posts
    259 Global Posts
    #13  
    Quote Originally Posted by 6tr6tr View Post
    Yes, but it's useless for my needs. I really needed it to resize the camera images, but those are JPG's and WebView won't resize jpg's!!
    I think what I did was load the JPG into the webview and then save to a png. I used the /tmp folder for the destination, so saveViewToFile("/tmp/image.png"... or whatever, I'm going off the top of my head. Then use the resize with /tmp/image.png for input and then make the output the path and filename you need like: resizeImage("/tmp/image.png","/var/usr/palm/applications/com.mystuff.hello/icon2.png",.....

    Let me know if that works for you.
    LaunchPoint Speed Dial - There's no faster way to dial, email, or text, period.
  14.    #14  
    Quote Originally Posted by worthb View Post
    I think what I did was load the JPG into the webview and then save to a png. I used the /tmp folder for the destination, so saveViewToFile("/tmp/image.png"... or whatever, I'm going off the top of my head. Then use the resize with /tmp/image.png for input and then make the output the path and filename you need like: resizeImage("/tmp/image.png","/var/usr/palm/applications/com.mystuff.hello/icon2.png",.....

    Let me know if that works for you.
    Sadly, no, it fails because it cannot handle the large 1.4 MB images created by the camera!!

    When I used a 44 KB jpg, it worked. When I used an image created by the camera (but placed in my app folder), the WebView was blank/white and so was the png! Any idea why this is and if it can be fixed?
  15. #15  
    I'm going to be trying something like this in the coming weeks. Hopefully I can figure it out, or it gets resolved by then.
  16. worthb's Avatar
    Posts
    241 Posts
    Global Posts
    259 Global Posts
    #16  
    Quote Originally Posted by 6tr6tr View Post
    Sadly, no, it fails because it cannot handle the large 1.4 MB images created by the camera!!

    When I used a 44 KB jpg, it worked. When I used an image created by the camera (but placed in my app folder), the WebView was blank/white and so was the png! Any idea why this is and if it can be fixed?
    Though it's been a while, I do remember a couple of things:

    1. It seemed to take a bit of time for the webview to display its content, at least the way I was using it (I was trying to embed it at the bottom of a scene, rather than having a scene that was just the webview, which may have worked better). The webview would appear blank, but if I tapped in it or "pinched" to zoom in or out, it would suddenly display its contents.

    2. Remember that so much of webOS is asynchronous, so you may need to change the order in which you are doing things to make sure the webview has the image loaded before attempting to save the view to an image file. Try the following:

    a: (the quick and dirty interactive approach) Push your scene that contains the webview. Design the scene with a "Save" button at the top of the page with the webview below it, or overlay the "Save" button on top of the webview with a z-index that forces it to appear in front of the webview. When your scene appears, as mentioned in (1) above, try scrolling or zooming the webview and see it the image eventually appears. It may take a few seconds because of the size of the image. After the image appears, tap the "Save" button that will then call an event handler with your saveViewToFile function.

    b: (maybe the "correct" approach, but you may want to try (a) first) The webview has a number of events that you can listen for that let you know when the content has been fully loaded etc. Check the API docs for the specifics, but set up an event listener that will wait until the webview has completed loading before executing the saveViewToFile function.

    Good Luck!
    LaunchPoint Speed Dial - There's no faster way to dial, email, or text, period.
  17.    #17  
    Quote Originally Posted by worthb View Post
    b: (maybe the "correct" approach, but you may want to try (a) first) The webview has a number of events that you can listen for that let you know when the content has been fully loaded etc. Check the API docs for the specifics, but set up an event listener that will wait until the webview has completed loading before executing the saveViewToFile function.

    Good Luck!
    That's the thing, I'm actually calling saveViewToFile in the event handler for "webViewDid FinshDocumentLoad". Yet, it's still blank. I'll try a couple other options but I'm not too hopeful with that. You wouldn't happen to have some of your old code, would you?

    (BTW, the above event gets thrown but: "webViewDownloadFinished" never does, even with a small jpg)

    BTW, thank you so much for helping me on this!
    Last edited by 6tr6tr; 09/30/2009 at 10:09 AM.
  18.    #18  
    Unfortunately, it didn't work. I put the saveViewToFile in a button press and I spent about 60 full seconds trying to expand, contract the webview and it never showed up. I then loaded the app again and let the webview and the scene sit there for 3 full minutes, then tried expanding/zooming in and then the button press - nothing. Argh! Any ideas?
  19. worthb's Avatar
    Posts
    241 Posts
    Global Posts
    259 Global Posts
    #19  
    Quote Originally Posted by 6tr6tr View Post
    Unfortunately, it didn't work. I put the saveViewToFile in a button press and I spent about 60 full seconds trying to expand, contract the webview and it never showed up. I then loaded the app again and let the webview and the scene sit there for 3 full minutes, then tried expanding/zooming in and then the button press - nothing. Argh! Any ideas?
    You may try creating a local .html file with a <img /> tag with src = the jpg file you are trying to view. Just add the html file to your project in the main app directory alongside your main index.html. Then pass the file name as a file:/// url. You should be able to scale the image by specifying width and height parameters in the <img /> tag. This may let you skip the resize step later.

    Unfortunately, I don't have any code from before. I honestly spent less than 20-30 minutes just fooling around before I changed directions and gave up on what I was trying to do at the time. I do need to re-address this same issue soon, though, so hopefully you will make some headway, or if not I will be able to actively join you soon in trying to find the best way to make this work.
    LaunchPoint Speed Dial - There's no faster way to dial, email, or text, period.
  20.    #20  
    Quote Originally Posted by worthb View Post
    You may try creating a local .html file with a <img /> tag with src = the jpg file you are trying to view. Just add the html file to your project in the main app directory alongside your main index.html. Then pass the file name as a file:/// url. You should be able to scale the image by specifying width and height parameters in the <img /> tag. This may let you skip the resize step later.
    It's funny, I actually tried exactly that when the first way didn't work but it also does not work.

    Quote Originally Posted by worthb View Post
    Unfortunately, I don't have any code from before. I honestly spent less than 20-30 minutes just fooling around before I changed directions and gave up on what I was trying to do at the time. I do need to re-address this same issue soon, though, so hopefully you will make some headway, or if not I will be able to actively join you soon in trying to find the best way to make this work.
    Please do join me soon, 'cause this is killing me. ...

    Instead, I'm looking into writing a jpeg decoder/encoder to resize it that way, but what a pain! And it might be super slow in javascript.
Page 1 of 2 12 LastLast

Posting Permissions