Storing Image Thumbnail INTO Image in Android - java

I am implementing a gallery of images that are stored in a folder in the SD card. The images are copied from the server. I am trying to display thumbnails using the Interface ExifInterface. It has a very nice method getThumbnail. This method returns a thumbnail if it exists or null if not. But the condition is that the image NEEDS to contain the thumbnail WITHIN.
My Question is: How can I create a thumbnail INSIDE the image when I save the image to SD card so that ExifInterface.getThumbnail detects that thumb and does not return null

You can create your own thumbnail with ThumbnailUtils class (added in API level 8).
Bitmap source = BitmapFactory.decodeFile(pathToImage);
Bitmap thumb = ThumbnailUtils.extractThumbnail(source, thumbWidth, thumbHeight);
ExifInterface class is very limited, so you cannot attach thumbnails.

Related

How to save bitmap in new folder in DCIM to show it in gallery on cellphone (the cellphone doesn't have SDCard)?

I have an URL, I download the image in it and convert it to bitmap. I want to download the bitmap in the internal memory of the cellphone to be in the gallery. I found solutions but includes SDcard and I need to save the image even if the cellphone doesn't have external memory. How can I achieve that?
Well not all cam app store on DCIM but you can
MediaStore.Images.Media.insertImage(
getContentResolver(), bitmap,
System.currentTimeMillis() + ".jpg", "DESCRIPTION HERE");

How to add src path image to my pdf using Image.getInstance() method?

Here in my web-application under Images folder pdficon.png image is available I want to add this image using Image.getInstance() method but whaen I tring like this..
image = Image.getInstance("images/pdficon.png");
Here it showing Exception is
IOException :: C:\Users\Developpc\Downloads\wildfly-9.0.2.Final\bin\images\pdficon.png (The system cannot find the path specified)
So,what I need to do....
Signup for some free image hosting account and upload your image. After uploading your image you can get the URL of the image and put that URL for image.getInstanceMethod.
Image img = Image.getInstance(IMG_URL);
If you are using that image multiple times then create an string constant and use that.

Save image in SD card after picasso load image

I am using picasso plugin to load image.
Picasso.with(context).load(BackendConfig.media_url+folder+holder.media_name).resize(150, 150).into(holder.imageView);
It's working fine. But, I want to save that image in SD card by loading just once from URL.
How can I do that?
Picasso using LRU disk cache, no need to worry about loading it from URL once. If you need to load and save actual image as file, load it as bitmap resource instead, and use Bitmap.compress and FileOutputStream to save into file (PNG/JPEG/WEBP).
you can use this lightweight android library VINCI (wrot this for my self) its do every thing you want
caching - using LruCache
managing files/bitmaps (Saving files in internalStorage)
read this WIKI part for more visit my github repo .
Storage store = Vinci.base(context).process().load(uri).file();
Log.e("Created", Boolean.toString(store.isCreated()));
Log.e("FileObject", store.FileObject().toString());
Log.e("FullPath", store.getfullPath().getPath());
Log.e("LocalPath", store.LocalPath());
Log.e("Get Bitmap File", String.valueOf(store.getBitmap()));

Caching Zoomable Web Image

Aquery
Zoomable Web Image
In addition to ImageView, a WebView can be used to display an image along with Android build in zoom support for WebView. Image will be centered and fill the width or height of the webview depending on it's orientation.
I using,
String url1 = "file:///mnt/sdcard/image.jpg";
aq.id(R.id.webView1).progress(R.id.progress).webImage(url1);
I noticed that even if I cut off the connection and re-open that application, the image is still displayed. Is it cached? I looked into its sd card folder, nothing there. I'd like to utilize cached images instead of fetching it many times.
Also, I am both using Universal-Image-Loader and Android Query. I am just concern if they can both read cached images.
//Aquery
//returns the cached file by url, returns null if url is not cached
File file = aq.getCachedFile(url);
The url1 is being downloaded every time you call
aq.id(R.id.webView1).progress(R.id.progress).webImage(url1);
Your cached file is being returned to File file object but you arent making use of it in

How to load an image in Java using toolkit and new URL

I need to use a JPEG image in my Java applet.
In my applet class, I define the image name and create an object to ImageBuffer class.
String iname= "image1.jpg";
b = new ImageBuffer(iname,this);
In the ImageBuffer class, I call
Image image = null;
image = Toolkit.getDefaultToolkit().getImage(new URL(applet.getCodeBase(),fileName));
While this does not flag an error and image is not null anymore, it does not initialize image correctly. The height and width are -1. The url of the path however appears to be correct : /C:/Users/..../image1.jpg
How do I correctly load the image? It is in the bin file of my Eclipse project currently.
The height and width are -1.
Use a MediaTracker to monitor the asynchronous loading progress of the image. Alternately use ImageIO to load the image prior to the next code line.
If the image is placed in the correct location, then this would fix it
image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(new URL(applet.getCodeBase(),fileName))).getImage();
If the code returns a NullPointerException it means the image is not placed in the correct directory.

Categories

Resources