Possible Methods to retrieve image from server - android

I am developing an application where it should get data from my server with respect to the ID Number , and also I need to take an image from database , according to the id number. So I went to an option of loading url image. There I could not able to get large size images. So I went to converting the image to base64 format and sending it through webservice. Even in that I was able to retrieve small size strings , but when I go for big size of images, the base64 string is bigger. So looking for possible answers, any way thanks in advance...

Sending photos in binary form over a HTTP connection is a solved problem. I suggest you go with an off-the-shelf web server and call it a day. To send reduced-size images, install a script that (in response to a URL that indicates desire for a thumbnail) will check for thumbnails; create them if they don't exist; and then serve as images in the standard manner. Don't worry about base64 unless you're dealing with really ancient services that don't understand pure binaries. If you do go the route of base64, don't worry about file-size expansion. Unless you're sending huge numbers of images, it's not that significant.

I had this problem and had to use ftp server. I put my image files into a ftp server and download each one I need.

Related

How to send big size image to a server in android?

I have to send a DNG file which has a size around 30 mb to my server and then I have to process DNG file in matlab and after that I need to get the results back from matlab to android device. I am new to sending images to a server and I do not know if is there any special way for big size images. I saw similar questions but I could not understand what to do for sending images to a server.
Could you please help me which steps should I follow respectively and which methods or libraries do I need to use ? Thanks.
If you'd like to send big files using HTTP, chunks are the way to go.
You would need a backend server supporting this kind of operation (either with some homemade recipe or with a standardized implementation).
You'd basically need an API to create the file description (including the expected size) which would return a handle on this future file (at least an ID). Then use PUT or PATCH and send the chunks one by one.

What is the best way to save images in Parse?

What am I trying to achieve: Based on some filters by the app user, I want to return a list with text and images.
How am I doing it: I have created a table in Parse and have added a column with object type as 'file'. I have put all the jpg/gif images into that column. (double-click, browse, select image from local computer).
The trouble I am having is, the list takes considerable time (~7 seconds) before it is displayed on my android app.
Is there a better way of handling image data within Parse or should I store images somewhere else (like Amazon S3)?
I am using standard queries for Parse in order to get data, nevertheless, am also checking if there is any code latency. Wanted to confirm if I am correctly handling the image data for back-end or not.
Is there a better way of handling image data within Parse or should I
store images somewhere else (like Amazon S3)?
If your images is not too much or you are using for example(five image) its better to save the into the Assets or Drawable Folder for loading.
and if i correctly knows about this problem, you need to use ProgressBar and one image, before loading the Images in Internet.
Caching images and displaying
Hope this helps.
I am using Parse to store images too, but it's not slow as you said. Since Parse is part of Facebook, I think their infrastructure is the same. There are possible issues:
Internet connection: Slow or on 3G?
Images: files are big?
Let me know which case you are in.
If you just display thumbnail images, I suggest you to process it before saving to Parse by writing Cloud function as describe on their blog. The you just need to use generated thumbnails on your listview/gridview

What's the best way to send images between users, and keep it in a server for a time in Android?

My application requires sending images between users, and sometimes these images may be consulted by other users ..
What is the best way to be sent or stored on the server? I have read can be uploaded to an FTP server and I have also read that they can be converted to a string in BASE64 and save the string in my MySQL Database .. and to display them they would have to be decoded.
What do you recommend?
Thank you!
This is a topic of great debate on the internet (even here on stackoverflow), check this URL:
http://research.microsoft.com/apps/pubs/?id=64525
The main conclusion is that if size of your image is less than certain size ( 200 KB i guess, not sure as i had read it a while back ), then its faster to read images from database, otherwise you should go with file system and just store the path and name combination of the image resource in database. Plus the file system approach is more scalable as well. Most large organizations prefer the file system approach.
Hope that helps ...

Android - Efficient way to load multiple images from remote server

I have an Android application that would retrieve data (images+text) from a php remote server and display them in a GridView.
I am doing the operation in the background using Loaders. I have separate connections for images and texts since retrieving images would take longer and I want to display the texts immediately. The texts are encoded with Json on the server after being retrieved from MySQL. On the app, I am parsing the Json Objects and displaying the texts as I need.
The problem is with images. I am not sure if encoding the images with Json would be a good idea. Also the images are saved as blob in the database, in order to encode them with Json I need to use base64_encode() before which is not efficient. I have seen many posts about this, but it’s always a simple example when you have to get one image. In my case I’ll be retrieving up to 30 small-size images.
My question is, I can proceed with what I just presented, but it seems that there should be a better way to do this. What do you think about this? Am I going the wrong way?
Also I was thinking if I can display each image separately in the gridview once it is ready (not waiting for all the images to be ready) just like in the “Google Play App”’s GridView. What approach can I take to achieve this?
Thanks in advance folks!
Best approach in my eyes would be to download the image files as normal image files via a HTTP get request. Make sure it is threaded of course, and have a thread pool that you can queue up requests into, and have 2-3 threads go through and download.
In terms of saving them, I would personally move away from saving to blob in a database, and opt to save them to the persisted storage in your application's private directory. Saving the image files with their filename as their id in the database you have created will be much quicker for loading them back in.
You can also hold a reference to the ImageView, and have it display a place-holder initially, with a successful HTTP request replacing the bitmap of the ImageView with the one you have just downloaded/read in from storage.
You can also do some image caching within the HTTP request you make.
ImageView myImageView = findViewById(R.id.testImage);
URL url = new URL("http://www.website.com/image.jpg");
URLConnection connection = url.openConnection();
connection.setUseCaches(true);
Object response = connection.getContent();
if (response instanceof Bitmap) {
Bitmap bitmap = (Bitmap)response;
myImageView.setBitmap(bitmap);
}
It also may be helpful to lookup the uses of the LRUCache, which performs a lot of caching functionality for you.
Check out this link at the Android Developer site for a good in depth guide to image caching
Edit:
You can use the advice in Robert Rowntree's answer to load bitmaps more efficiently to cut down on your memory use as well. The link provided details loading of bitmaps using less memory, something that would work well if you are creating thumbnails from larger images downloaded over the web and saved off to local storage.
IMO - there are 2 issues , moving the images across the network to the client and getting them loaded.
Assuming that you are using http as the protocol, you should have a multithreaded solution for http as is available in apache httpclient package. That will get the pictures to the phone fast.
Then , you have to present the pics by getting them into memory and a cache. Here you can consider what 'gallery3D' app does with its grid and bitmaps but its pretty complicated to read thru that code.
check out - http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
check out code samples for loading thumbs from bitmaps.

What is best way to upload images from mobile (iOS or Android) to server

I want to send a picture from my mobile to my server, and i know how to send it using base64 but i've heard that base64 is not recommended to use because base64 encoding increases the size of image by 37%, which in case slows down the performance of server because there will be too many images shared by users on the server.
can anyone recommend me the efficient technique than base64 encoding for the mobile based image sharing application (client-server app)?
You could simply POST your image (in regular UTF-8 encoding) as explained here: NSData and Uploading Images via POST in iOS. You will need to have some server-side servlet or php page to decode the image and save it.
You can use FTP, for uploading and downloading images from iPhone. The main advantage of using FTP over other methods is that we can set the bytes width per second to certain limit and can detect how much data has been transferred till Particular event.
Here is the code given by apple documentation to illustrate the uploading and downloading of any data (image, pdf, video or audio anything) over FTP.
http://developer.apple.com/iphone/library/documentation/Networking/Conceptual/CFNetwork/CFFTPTasks/CFFTPTasks.html#//apple%5Fref/doc/uid/TP30001132-CH9-SW1
Also refer this PDF for better understanding
http://developer.apple.com/iphone/library/documentation/Networking/Conceptual/CFNetwork/CFNetwork.pdf

Categories

Resources