09-20-2010 07:32 AM
I am sending an image to a webservice, The Image sends and everything is working fine. The only problem i am having now is that it takes long. What factors are involved here that could be "tweaked" to reduce the time it takes to send it to the webservice. Except the size of the image, Which i have catered for.
Thanks in advance.
09-20-2010 07:38 AM
base64 encoded images are about 1/3 bigger, that's what you sacrificing i guess
09-20-2010 07:57 AM - edited 09-20-2010 07:59 AM
Thank you for your replies,
This is the code snipit of how i send the image
Location location = lp.getLocation(timeout); longitude = location.getQualifiedCoordinates().getLongitude(); latitude = location.getQualifiedCoordinates().getLatitude(); SoapObject request = new SoapObject("http://tempuri.org/", "SaveLocation"); request.addProperty("image",Base64.encode(_raw)); request.addProperty("Long", longitude + ""); request.addProperty("Lat", latitude + ""); request.addProperty("notes", descrip.getText()); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut = request; envelope.dotNet = true; envelope.encodingStyle = SoapSerializationEnvelope.XSD; ht = new HttpTransport("url");
Sorry for the above format it does not seem to want work with me
Any advise on how to improve this will be greatly appreciated.
09-20-2010 08:12 AM - edited 09-20-2010 08:24 AM
I presume the image is a jpg? If not what format is it?
As Simon says, you are making it larger using Base64 which is not helping. But not sure what else you can do here.
09-20-2010 08:19 AM - edited 09-20-2010 08:23 AM
The image extension is in .bmp format, The image's source comes from the BB Devices camera. What should i use other than Base64 if there is a better way ? If you have do this before could you inform as to what the acceptable time it should take to send an image to a webservice ?
Again i cannot thank you all enough for your help and advice
09-20-2010 08:30 AM
You have to encode binary data in some way to transport in an XML format - Base64 is as good as any I am aware of. Maybe Simon has another option.
Re the format, the camera normally delivers in jpg format doesn't it. If not than converting to a jpg would make the image significantly smaller, though it is a lossy compression. Perhaps png? I must admit that I have never done either. When I have sent pictures back from the camera, they were jpgs.
Re time, as noted above, it dopes depend on the connection type. For a slow GPRS service I work on 1K per second. Have you considered only dong this over WiFi?
09-20-2010 08:34 AM
no other(better) options from my side. i usually try to upload binary data in binary format, but if you are required to use a webservice for it, not your fault.
09-20-2010 08:57 AM
Thank you Simon and Peter,
So basically what i have done with the code above, is pretty much acceptable ? The speed is just one of those things a person must deal with ?