Which is the fastest and best way to get image from server in android
app.
1. Image url
2. base64 format
or any other format which load image very quick as on normal internet speed.
As mentioned here base64 format is %37 larger than normal image. So if you use base64 format, you will have larger image and longer download time. In this case, you need to use normal image url.
To download images as fast as possible, you can use Picasso or Glide.
Just use glide for faster image load in your application because glide uses caching of images and it loads an image after compressing it a little bit. Even Google recommend this library to developers , Google used this library in Gmail.
Related
I'm loading images from external URLs with Picasso. To prevent someone from hosting huge files that would hang my app I would like to set a max image file size before downloading it.
Is there a way in Picasso to limit the file size? If no, what's an alternative?
You'll have to provide your own OkHttpClient to Picasso (via its Builder) to handle that. Generally speaking you'll need to issue a request to the server to figure out the size of the image and only then decide if you want to get it or not. Check this answer for more details.
I have a small problem, as I could convert a url from an image to a bitmap. The url string is obtained through a json that I download with Volley, and I need that bitmap to be able to give a personalized icon to a marker.
I think you can use Picasso Library here, and it will show the image with the given URL dynamically. There is much more benefits of using Picasso. Try that if it helps you.
And also there is no need to download the image to the user. It saves images cache to show the image if user returns in particular time-gap.
Volley supports loading images asynchronously to a bitmap.
Picasso supports loading images asynchronously to a bitmap.
Other image loading libraries may offer similar options, though since you already use Volley and Picasso, you may wish to stick with one of those.
I have a image uploading module in my app where user can select an image from the gallery. The problem is the size of the image can be upto 10MB. Which is very large, I want to apply some compression technique to these images before uploading them.
I did some research on the internet and found some libraries like ImageMagick, ImgMin which allows easy optimization of the images. Is there any way I can use them in my android project without the involvement of any backend server.
References:
ImgMin
https://github.com/rflynn/imgmin
ImageMagick
http://www.imagemagick.org/script/index.php
An easy option you can try is this method from the Bitmap class.
You can select the compression format of a bitmap and to optimise either the quality, or the file size. A downside is that the you need to get a Bitmap instance to start the compression, which may be something you don't want to do.
I am using Cloudinary to upload pictures from Android, but since they are usually a bit large I would like to generate a thumbnail for it that has a different URL.
This will allow me to have a full-resolution and a low-resolution version but only uploading the large picture.
I know I can use eager transformations, but I couldn't find a way to also get a different URL for the transformed one.
The equivalent would be for me to upload the full-res version and then do a new upload with the eager transformation. But that would increase the amount of data transfer my Android app needs, for what is essentially the same information.
So instead of upload full-res->get url->upload low-res->get url, I want
full-res->get both urls
Is there any way I can upload only once and get two URLs for the different versions?
Thanks!
As Cloudinary's transformation string is included in the URL itself, the transformed image's URL is different than the original one.
For example:
http://res.cloudinary.com/demo/image/upload/sample.jpg
vs.:
http://res.cloudinary.com/demo/image/upload/w_200/sample.jpg
So i´m creating a app in Android which stores images in a external server. I want to know where is better to make the optimization of the image file, in server, or give the non-optimize image to local and then optimize inside the app. Im using mysql for store the images, but if its better to use sqlite server i will change it. Thanks.
The best thing to do here is create an application on your server exposed through an API with query parameters to specify image sizes + caching mechanism.
For example:
www.mywebsite.com/imageloader/file-identifier?width=50&height=50&format=png
then implement a caching mechanism take a look at (https://dev.mysql.com/doc/refman/5.1/en/ha-memcached.html) for mysql on the server for this image using these parameters so the application can quickly return this file each time and not require too much work from the application. This will allow you to request multiple images at specific sizes when you need them for example only as a thumbnail... Or a full Gallery image which can be something much larger.
Additionally you will want to use an Image Library and there are certainly quite a few for Android (to name a few):
Picasso from Square http://square.github.io/picasso/
Fresco from Facebook https://github.com/facebook/fresco
Ion from this Github https://github.com/koush/ion
These can all help you format your images and cache them locally and even downsize the images as necessary.