Image picker java android

Image picker java android

📸 Image Picker Library for Android

Easy to use and configurable library to Pick an image from the Gallery or Capture image using Camera. It also allows to Crop and Compresses the Image based on Aspect Ratio, Resolution and Image Size.

Almost 90% of the app that I have developed has an Image upload feature. Along with the image selection, Sometimes I needed a crop feature for profile image for that I’ve used uCrop. Most of the time I need to compress the image as the image captured from the camera is more than 5-10 MBs and sometimes we have a requirement to upload images with specific resolution/size, in that case, image compress is the way to go option. To simplify the image pick/capture option I have created ImagePicker library. I hope it will be useful to all.

  • Pick Gallery Image
  • Pick Image from Google Drive
  • Capture Camera Image
  • Crop Image (Crop image based on provided aspect ratio or let user choose one)
  • Compress Image (Compress image based on provided resolution and size)
  • Retrieve Image Result as Uri object (Retrieve as File object feature is removed in v2.0 to support scope storage)
  • Handle runtime permission for camera
  • Does not require storage permission to pick gallery image or capture new image.
Profile Image Picker Gallery Only Camera Only

If you are yet to Migrate on AndroidX, Use support build artifact:

The ImagePicker configuration is created using the builder pattern.

Kotlin

Java

Override onActivityResult method and handle ImagePicker result.

Inline method (with registerForActivityResult, Only Works with FragmentActivity and AppCompatActivity)

i. Add required dependency for registerForActivityResult API

ii. Declare this method inside fragment or activity class

iii. Create ImagePicker instance and launch intent

Pick image using Gallery

Capture image using Camera

Crop image with fixed Aspect Ratio

Crop square image(e.g for profile)

Compress image size(e.g image should be maximum 1 MB)

Set Resize image resolution

Intercept ImageProvider, Can be used for analytics

Intercept Dialog dismiss event

Specify Directory to store captured, cropped or compressed images. Do not use external public storage directory (i.e. Environment.getExternalStorageDirectory())

Limit MIME types while choosing a gallery image

You can also specify the request code with ImagePicker

Add Following parameters in your colors.xml file, If you want to customize uCrop Activity.

  • Library — Android Kitkat 4.4+ (API 19)
  • Sample — Android Kitkat 4.4+ (API 19)
  • Added uzbekistan translation (Special Thanks to Khudoyshukur Juraev)
  • Removed requestLegacyExternalStorage flag
  • Removed unused string resources
  • Added arabic translation #157 (Special Thanks to zhangzhu95)
  • Added norwegian translation #163 (Special Thanks to TorkelV)
  • Added german translation #192 (Special Thanks to MDXDave)
  • Added method to return Intent for manual launching ImagePicker #182 (Special Thanks to tobiasKaminsky)
  • Added support for android 11 #199
  • Fixed android scope storage issue #29
  • Removed storage permissions #29
  • Fixed calculateInSampleSize leads to overly degraded quality #152 (Special Thanks to FlorianDenis)
  • Fixed camera app not found issue #162
  • Fixed Playstore requestLegacyExternalStorage flag issue #199
  • Added dialog dismiss listener (Special Thanks to kibotu)
  • Added text localization (Special Thanks to yamin8000 and Jose Bravo)
  • Fixed crash issue on missing camera app #69
  • Fixed issue selecting images from download folder #86
  • Fixed exif information lost issue #121
  • Fixed crash issue on large image crop #122
  • Fixed saving image in cache issue #127
  • Added option to limit MIME types while choosing a gallery image (Special Thanks to Marchuck)
  • Introduced ImageProviderInterceptor, Can be used for analytics (Special Thanks to Marchuck)
  • Fixed .crop() opening gallery or camera twice #32
  • Fixed FileProvider of the library clashes with the FileProvider of the app #51 (Special Thanks to OyaCanli)
  • Added option to set Storage Directory #52
  • Fixed NullPointerException in FileUriUtils.getPathFromRemoteUri() #61 (Special Thanks to himphen)
  • Fixed UCropActivity Crash Android 4.4 (KiKat) #82
  • Fixed PNG image saved as JPG after crop issue #94
  • Fixed PNG image saved as JPG after compress issue #105
  • Added Polish text translation #115 (Special Thanks to MarcelKijanka)
  • Failed to find configured root exception #116
  • Improved UI/UX of sample app
  • Removed Bitmap Deprecated Property #33 (Special Thanks to nauhalf)
  • Camera opens twice when «Don’t keep activities» option is ON #41 (Special Thanks to benji101)
  • Fixed uCrop Crash Issue #42
  • Fixed app crash issue, due to Camera Permission in manifest #34
  • Added Option for Dynamic Crop Ratio. Let User choose aspect ratio #36 (Special Thanks to Dor-Sloim)
  • Optimized Uri to File Conversion (Inspired by Flutter ImagePicker)
  • Removed redundant CAMERA permission #26 (Special Thanks to PerrchicK)
  • Sample app made compatible with Android Kitkat 4.4+ (API 19)
  • Fixed Uri to File Conversion issue #8 (Special Thanks to squeeish)
  • Added Support for Inline Activity Result(Special Thanks to soareseneves)
  • Fixed issue #6
  • Optimized Compression Logic
  • Replace white screen with transparent one.

We’ll be really happy if you sent us links to your projects where you use our component. Just send an email to dhavalpatel244@gmail.com And do let us know if you have any questions or suggestion regarding the library.

About

📸 Image Picker for Android, Pick an image from Gallery or Capture a new image with Camera

Источник

3.0.0-beta1: Hash code and equals (#354)

Hopefully, the last version until we hit 3.0.0.
All fixes now should only be applied to this version.

Assets

  • Fix folder name & image name NPE #316
  • Add optional save image functionality #312
  • Fix Display Video Crash a26b0f6
  • Japanese support #332

Thanks to all the contributors! 🔥

Assets

Android Q Fixes, Initial Kotlin Migration

  • Add getUri() for convenient #285
  • Fixes for Android Q #290#293
  • Fixed some typo #291
  • Show video duration on the image picker #271
  • Use github workflow instead of CircleCI
  • Migrate sample to Kotlin #295

Assets

2.3.0 — Android Q Support!

  • Fix failed to create image file #262
  • Handle external scoped Glide issue
  • Bump target SDK to Q
  • Bump Glide to 4.11.0

Assets

  • Configurable ImageFileLoader
  • New approach on how to set custom ImageLoader
  • Fix and improvements

Assets

2.1.0: Merge pull request #222 from mnayef95/only-video-support

  • Support video only picker
  • Fix #188
  • AGP 3.4.2

Assets

  • ImagePicker is now in Fragment and you can use it in custom UI (please see sample)
  • Remove Retrolambda
  • Compatibility with Glide 4.9.0
  • Add Option to exclude GIF from image picker
  • Bug fixes and improvements

Also, we integrate our repo with CircleCi and add issue templating, because we want to improve our development experience in general

Assets

Fixing long loading time in image picker

Assets

  • Back arrow support RTL
  • Update to AGP 3.1 and Gradle 4.4
  • Add Arabic translation
  • Better permissions handling for cameraOnly mode
  • Basic video support
  • Set language programmatically
  • Some internal changes

Assets

New ReturnMode API and many more!

  • [New] Return Mode API returnMode

So if you want to mimic the setReturnAfterFirst behavior, all you have to do is

  • setReturnAfterFirst is now obsolete
  • [New] set toolbar arrow color with toolbarArrowColor(int color)
  • Rename ImagePicker methods
    • folderTitle -> toolbarFolderTitle
    • imageTitle -> toolbarImageTitle
  • Add capability to start without a request code

So instead of this

Now you can do this

BUT, you have to handle the result with the helper method from ImagePicker

You can still use the usual result check if you define the request code by yourself.

Источник

Android Image Picker Library | Top 15 Curated List

Up next

Checkboxes In Android Example with Source Code
Share article
What’s in this blog? Hide

Android Image Picker Library can help you in your Android Project to help user select images from their media folder or from the camera of their android device.

Here is a curated list of 15 such libraries built by developers to help you make choice for your Android Project with link to their respective github repository and gradle implementation code.

Android Image Picker Library mentioned below are not in any ranking order, however they are stable and tested

BottomSheet Image Picker Library

A modern image picker implemented as BottomSheet.

Language Java, Kotlin
Min SDK 17 (4.2 Jellybean)
Size 923 kb

Features

  • Select single/multiple images right in the bottom sheet
  • Use camera to take a picture
  • Choose image from gallery app
  • Handles all permission requests

This library is based on BSImagePicker. The developer, siralam reimplemented everything in Kotlin and added some features. Also, siralam used the new androidX artifacts.

Add to Project

First make sure jitpack is included as a repository in your project‘s build.gradle:

And then add the below to your app’s build.gradle:

BSImagePicker

An image picker that extends BottomSheetDialogFragment. Camera and gallery all in one dialog. Single or Multi Selection.

Language Java
Min SDK 16 (4.2 Jellybean)
Size 1500 kb

When your app needs user to pick one or more images from their device, it is still quite painful in Android.
Without any customization, you first need to ask user whether he/she wants to take a picture using camera, or select one from a Gallery app.
Then you have to write quite some code to launch a Camera intent.
Not to mention that you cannot even let user select multiple images.

So an image picker that solves all these pains is almost present in every app. And this library does the below:

  1. Without the need to ask user whether to take photo or select from gallery, these options are all in one dialog;
  2. Works for both single and multiple selections;
  3. Handle asking permissions for you;
  4. You just need to show this dialog, and register callbacks that give you a Uri or List .

The UI design of this library is referenced from TedBottomPicker.

Add to Project

First make sure jcenter() is included as a repository in your project‘s build.gradle:

And then add the below to your app’s build.gradle:

You also need to make sure you have included ‘com.android.support:support-v4: in your dependencies.

Multimager

Multi Image Picker and Multi Image Capture Demo app This is a sample demonstration for multiple images capture as well as multiple image picker. UX/UI can be styled with any color with relativity to Material Design. The demo shows tinting multiple views based on theme color!!

Language Java
Min SDK 16 (4.1 JellyBean)
Size 7400 kb

Add the jitpack repo to your repositories section in root level build.gradle

Add the dependencies to the app level build.gradle

AsyncFilePicker Android Image Picker Library

File picker allows you to take photo and files from camera\gallery\filesystem and also you can add up to 3 own custom actions.

Picker will ask for camera and gallery permission on android version 6.0 or above.

To add this library to your project, you must add the JitPack repo to your root build.gradle file…

Then include this in your dependencies block

Language Kotlin
Min SDK 17 (4.2 Jellybean)
Size 230 kb

Universal Media Picker

Easy customizable picker for all your needs in Android application

Add following line of code to your module(app) level gradle file

Language Kotlin
Min SDK 14 (4.0 Icecream Sandwich)
Size 469 kb

MediaPickerLib

Kotlin based media picker library, to pick multiple images and/or videos from the built-in gallery. Easy to implement and use.

Add this on your module:app build.gradle

Gradle

Language Kotlin
Min SDK 19 (4.4 KitKat)
Size 2800 kb

ImagePickerUtil Android Image Picker Library

Android Imagepicker which allows to select images or capture from the camera with required permission and easy to implement, crop and compress the final image.

Add repository url and dependency in application module gradle file:

Language Java
Min SDK 16 (4.2 JellyBean)
Size 1700 kb

MultiPhotoPicker

Language Java
Min SDK 15 (4.0.3 – 4.0.4 IceCream Sandwich)
Size 1700 kb

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file

Step 2. Add the dependency

NaraeImagePicker

MultiImagePicker for Android Application, written in Kotlin

Language Kotlin
nMin SDK 16 (4.1 JellyBea)
Size 1700 kb

Usages

Matisse Android Image Picker Library

Matisse is a well-designed local image and video selector for Android. With Matisse you can:

  • Use it in Activity or Fragment
  • Select images including JPEG, PNG, GIF and videos including MPEG, MP4
  • Apply different themes, including two built-in themes and custom themes
  • Different image loaders
  • Define custom filter rules
  • More to find out yourself
Language Java
Min SDK 14 (4.0 Ice cream Sandwich)
Size – kb

Permission

The library requires two permissions:

So if you are targeting Android 6.0+, you need to handle runtime permission request before next step.

Android Image Picker Library -OLX

Combined both TedBottomPicker and Camera View, to get the View Similar to ImagePickers of Olx.

We can Pick Images From Gallery and Camera in two modes, Single and Multi.

Awesome Image Picker

Awesome Image Picker library will pick images/gifs with a beautiful interface . Supports image or gif, Single and Multiple Image selection.

Language Java
Min SDK 15 (4.1 JellyBean)
Size 1700 kb

Getting Started

In build.gradle (Project)

And then in the other gradle file(may be your app gradle or your own module library gradle, but never add in both of them to avoid conflict.)

Louvre Android Image Picker Library

A small customizable image picker. Useful to handle gallery image pick action built-in your app.

Getting Started

Add this in your root build.gradle file (not your app module build.gradle file):

Then, add the library in your app module build.gradle

Link to Louvre Android Image Picker Library

MediaPickerInstagram

Link to MediaPickerInstagram Android Image Picker Library.

Pix (WhatsApp Style Image Picker)

Pix is a Whatsapp image picker replica. with this Android Image Picker Library you can integrate a image picker just like whatsapp .

Getting Started

include in app level build.gradle

Pix is using the new Material Android Image Picker library with the legacy Support Library. You have to migrate from android.support to androidx in order to use com.google.android.material.

With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

For more details kindly refer Migrating to AndroidX

Interested in Animating your Android Views? Look here:
Android Animation Library | Top 20 Curated List

Источник

Читайте также:  Обои для андроид с лондоном
Оцените статью