How take photo and reduce image file dimension - android

in my android app i've implemented a method for taking a photo and save it in a folder specified by me.
I would like to automatically resize the image (or compress it) to reduce the file dimension under the 1MB, obviously before saving it.
Which is the best way to do this?
Thanks

Take a look at this: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html , it has good examples of how to keep your filesize down on photos

Related

Android how to load Image file with different extension using Picasso

This is a different situation. I want to load a image file which has stored with different extension like 'photo.xyz' instead of 'photo.jpg or photo.png' using Picasso. to avoid image from gallery i am storing image like this. Please help me is there any option to show like this.
Neither Picasso nor Android (which does the actual image decoding) cares what the file name is. It can be anything. The type of the image is always determined from the first few bytes of the actual image data.
As a small workaround you can programmatically put .nomedia file into your app folder to prevent images to be cached by mediaserver and displayed in a Gallery app.

Android Efficient Bitmap processing

My scenario:
In my activity, I have to show 2 galleries, 1 with large image and another is a thumbnail(same exactly like default Gallery application).
My doubts:
I am planning to save as 2 images(1 with large size and another one with thumbnail size) in sdcard for fast processing. Is that good practice? since it will increase the size.
Or Shall I resize the large image during the getView method of BaseAdapter to small size for displaying in thumbnail gallery?
Which one is the good practice? I don't want to slow down my app.
See this example.
I will suggest you that, put only your large image inside your sdcard. But at runtime, Android provides a good facility to get Thumbnails using MediaStore.Images.Thumbnails.
Edit:
You can also get use Loading Sample Sized Bitmap. This will first create a sample size of your requirement. Then will give you a Thumbnail sized Bitmap.
StackOverflowAnswers:
1) Get thumbnail of image on SD card

how to edit big images in android?

I am trying to save small images from the original which I load from SDcard. Android doesn't allow me to create bitmap of bigger image sizes so I had to use options, doing so my images' resolution is altered so now how i am supposed to edit the original image??
And saving images, do I have the bitmap.compress option alone? If so, this reduces the quality of the image when i open and save it in JPG
And how can I display them independent of the screen???
I found a way to display big image in Android by using BitmapRegionDecoder. http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html

How to compress picture and create File from picture Uri

I have Uri of some image at my external storage but it is too large. I have constructor further which accepts only File like parameter. How to make picture smaller adn get File from that ?
Well that depends on how you're displaying the picture. If you're simply going to show that picture in your layout, just size the ImageView element appropriately in your respective layout.xml file:
android:minHeight="your_value"
android:minWidth="your_value"
Also, don't forget to set the adjustViewBounds property as well:
android:adjustViewBounds="true"
If you're looking for something a bit more robust and you're concerned about the memory used to store the entire bitmap for display, then I'd look into using the BitmapFactory class and specifically the inSampleSize field.
This previous question also provides some background for you.

Android image capturing and scaling

I am using the Camera activity to capture the JPEG image. After image is saved and the controll is returned back to my application activity I would like to to determine the captured JPEG image dimensions without loading the whole image into memory via Bitmap object - can it be easily done somehow?
Is there any class, which reads the JPEG header and give me such information? I would like to avoid OOM conditions - but might be it is not a problem to load the whole image into memory - is it?
After knowing the dimensions I would like to use BitmapFactory to scale the image.
Thanks a lot
Kind Regards,
STeN
Perhaps a work-around (see 2nd approach) by setting the quality?
bmp.compress(CompressFormat.JPEG, 75,
pfos);
You would have to do a trial run to see what size the quality gets you though...
*The first approach creates a log file to get the width and height but not sure if you wanted the extra step of looking at a log file.
You can use the ExifInterface class to read the image width and height.

Categories

Resources