Want to create tumbnails from url from any sites.
I am using following code
Bitmap bmThumbnail;
bmThumbnail = ThumbnailUtils.createVideoThumbnail(videoLink,
MediaStore.Video.Thumbnails.MICRO_KIND);
But its not working,please suggest any other ways if present.
Use Glide : https://github.com/bumptech/glide
Shortest Method To get Video thumbnails
RequestOptions requestOptions = new RequestOptions();
requestOptions.isMemoryCacheable();
Glide.with(context).setDefaultRequestOptions(requestOptions).load("Url").into(image);
If there is youtube url, then we have to make static url to make it thumbnail. https://img.youtube.com/vi/nE4PBsClUrY/0.jpg
nE4PBsClUrY - this is id of video
Using that we can make a thumbnail.
Related
I stored the path to my images in mysql db and was not sure if there's a way to load them in an imageView using volley library.
I'm able to parse string as json and display it in textView using volley string request queue but wasn't sure how I can get the path to display as image in my imageView. I would like to fetch the image using id.
Thanks in advance!
I always use the Glide to load images like this. Simply return the path like you do any other string. There is no need to load a bitmap with Volley, using Glide for this is simpler and better. Glide will handle for example image caching amongst other things.
This is all you need except from the Volley part.
ImageView imageView = findViewById(R.id.image);
String url = "www.foobar.com/" + path;
Glide.with(context).load(url).into(imageView);
Recently, I used Picasso library in my project and it worked fine and smooth. You can easily Load Image to ImageView from Url by using Picasso. Moreover, you can resize the original image to your desire size.
Example:
String mURL = "https:\/\/c.tribune.com.pk\/2017\/12\/1593389-vanga-1514310781-708-160x120.jpg";
ImageView Icon = (ImageView) findViewById(R.id.icon);
Picasso.with(context).load(mURL).resize(72, 72).into(icon);
Note: Using Picasso first you must import its library.
I used this: compile 'com.squareup.picasso:picasso:2.5.2'
use glide to display your image or you can use picasso
new ImageRequest(
url,
listener,
maxWidth,
maxHeight,
decodeConfig,
errorListener);
Response.Listener<Bitmap> listener = new Response.Listener<Bitmap>() {
#Override
public void onResponse(Bitmap bitmap) {
//here you set the bitmap to imageview
} };
The Android app allows users to select a photo from their phone gallery which I save the URI to realm. I then retrieve this information and use Picasso to load it into the image view. For some reason the image is not loaded.
The URI is something like:
content://com.android.providers.media.documents/document/image%3A333180
I save it to realm using mCategory.icon = imageURI.toString() and then when I load it:
Picasso.with(getContext())
.load(Uri.parse(mCategory.icon)) // mCategory.icon is a string
.resize(200, 200)
.error(R.drawable.mountain) // default image to load
.into(viewHolder.categoryIcon);
The URI you got is a ContentProvider URI to show it with Picasso you try to do this:
File file = new File(Uri.parse(mCategory.icon));
Picasso.with(getContext())
.load(file)
.resize(200, 200)
.error(R.drawable.mountain)
.into(viewHolder.categoryIcon);
P.S: Though you can convert your ContentProveder path to Absolute path still it's better if you don't since Picasso support loading from the File..
Use setLoggingEnabled(true) in picasso to check the log if there is any error message.
Mentioned URI contains the encoded value of colon : i.e. %3A.
Either rename the source OR try Glide or some other library to serve the purpose.
This is working perfectly with new version of Picasso 2.71828
Picasso.get()
.load(imageUri)
.placeholder(R.drawable.placeholder)
.fit()
.centerCrop()
.into(viewHolder.categoryIcon);
My drive url is -
https://drive.google.com/file/d/0B3DFHb2-MdGYa2NMUkVtVkZ1V1k/view?usp=sharing
I want to show it in android imageview using glide. I have tried many ways to show it.
Following is my code to show -
Glide.with(getActivity()).load(readExcelFeed.getImage().toString()).into(ivQueImage);
Please let me know what is the issue in it.
Steps for loads image from Google drive into ImageView by Glide Library
Step 1 : In your Drive which image you want to display on ImageView. You need to get shareable link from the three dots from the google drive. like this "https://drive.google.com/open?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9"
Step 2: Then the base url for display the image. link is
public static String BASE_URL = "https://drive.google.com/uc?id=";
Step 3 : In the Step 1 you see the id of the image then add this id in the base URL. Like this type
"https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9"
Step 4 : Use Glide library for display the image on ImageView Like this:
Glide.with(mContext)
.load("https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9")
.into(holder.user_image);
Now you can see your image on your ImageView.
Unless I'm missing something, you want to show just that single image using Glide. Just right click on it, select "Copy image address", then use that as your url String for Glide.
String url = "https://lh3.googleusercontent.com/s6-0yxPhDS4Os7SYbP66RCNp-mDwuKr72mLJx9ekuTWYFPgXahCvj-oVatwXELyVfyZzD80YTaiYde4=w1278-h954-rw";
Glide.with(getActivity()).load(url).into(ivQueImage);
For request image source you must use executeMediaAndDownloadTo()
service.files().get(fileId).executeMediaAndDownloadTo(outputStream);
Then you can get byte[] from output stream
byte[] data = outputStream.toByteArray();
and insert it to Glid
RequestOptions options = new RequestOptions();
options.skipMemoryCache(true);
options.diskCacheStrategy(DiskCacheStrategy.NONE);
Glide
.with(this)
.load(data)
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade())
.into(imageView);
I'm trying to load an image from the following url:
https://fangkarte.de:8080/fangfisch/file/files/592036af55dfffca0155e01fe10002f7
In Chrome/IE the image will be displayed without problems. When I try to load the image on Android I am not able to store the image as an PNG file. Everytime the image will be saved as a textfile which contains the image as base64 String.
Also I tried the following code but the decodedByte is null:
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
Does anyone have an idea how I can show my image from the url as an bitmap or which I prefer to store the image on the device as an png?
Use Universal Image Loder to upload image from Url
Download universal image loder and add to your lib folder and
Implement the below code where you want to load image
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(context));
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true)
.cacheOnDisc(true).resetViewBeforeLoading(true)
.showImageForEmptyUri(R.drawable.noimage)
.showImageOnFail(R.drawable.icon3)
.showImageOnLoading(R.drawable.loading).build();
imageLoader.displayImage(url, imageview, options);
For handling images, Use Picasso , Glide , Universal image loader, Volley or Fresco
Eg, in picasso, you will be able to load images, store them in memory cache and handle cancellations in listviews/recyclerviews etc...
Picasso.with(context).load("https://fangkarte.de:8080/fangfisch/file/files/592036af55dfffca0155e01fe10002f7").placeholder("someimagetillyourimagedownloads).into(R.id.yourimageview);
Picasso: https://github.com/square/picasso
Glide: https://github.com/bumptech/glide
Fresco: https://github.com/facebook/fresco ( I use this after extensively testing all 3 except volley )
UIL: https://github.com/nostra13/Android-Universal-Image-Loader
Similar things can be done using all the above libraries.
I highly recommend not trying to handle images on your own. It can turn into quite a mess if you are a novice android dev.
The image you download is much to big ((860.000 bytes)) to make a Bitmap out of it. So BitmapFactory will return null.
Scale image down before use.
How can I set an image to a ImageView from a URL?
Using Firebase authentication, I get the photo URL of the signed in user:
Uri uri = firebaseUser.getProviderData().get(0).getPhotoUrl();
You can use Picasso Library to show images in ImageView.
You just need to pass the url, uri or resource to Picasso with image view.
like
Picasso.with(this).load(/* url of image */).into(/*your imageview id*/);
To use the picasso you need to add the following in Gradle
compile 'com.squareup.picasso:picasso:2.5.2'
Read the documentation on http://square.github.io/picasso/
Also There are other libraries to display image in ImageView.
Like Fresco, Glide, Universal Image Loader etc