All Projects → Dhaval2404 → Imagepicker

Dhaval2404 / Imagepicker

Licence: apache-2.0
📸Image Picker for Android, Pick an image from Gallery or Capture a new image with Camera

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Imagepicker

Ypimagepicker
📸 Instagram-like image picker & filters for iOS
Stars: ✭ 3,661 (+487.64%)
Mutual labels:  camera, imagepicker, image-picker
Coco
基于kotlin、简洁易用的调用系统拍照或图片选择库
Stars: ✭ 276 (-55.7%)
Mutual labels:  camera, image, imagepicker
Insgallery
📸 Instagram-like image picker for Android (一款 UI 炫酷高仿 Instagram 的图片、视频选择器)
Stars: ✭ 409 (-34.35%)
Mutual labels:  crop-image, imagepicker, image-picker
Picker
Picker - A CameraX based WhatsApp Style Image-Video Picker
Stars: ✭ 69 (-88.92%)
Mutual labels:  camera, image, imagepicker
ProPicker
ProPicker is a file picker (image, video, file) library for Android. It helps you to pick any file and return the result in a convenient way
Stars: ✭ 25 (-95.99%)
Mutual labels:  camera, image-picker, imagepicker
Rximagepicker
Android图片相册预览选择器、支持AndroidX,支持图片的单选、多选、图片预览、图片文件夹切换、在选择图片时调用相机拍照
Stars: ✭ 85 (-86.36%)
Mutual labels:  camera, image, imagepicker
ConvenientImagePicker
🏞🌅🌄🎇🌇🏙🌃🌉🌁the new iOS image picker. Beautiful, delicate, and customizable.
Stars: ✭ 44 (-92.94%)
Mutual labels:  image-picker, imagepicker
Album
android 图片视频加载库,单选,多选,预览,自定义UI,相机,裁剪...等等 已适配android10,11
Stars: ✭ 53 (-91.49%)
Mutual labels:  camera, crop-image
Bottomsheet Imagepicker
Modern image picker for Android
Stars: ✭ 267 (-57.14%)
Mutual labels:  image, imagepicker
PhotoSelectAndCrop
This package integrates a UIImagePickerController into a SwiftUI app. Obtain 1) a copy of the original image, 2) a scaled and / or cropped version of it, 3) a CGFloat and 4) CGPoint. The CGFloat and CGPoint represent the scale and position of the original image used to make the processed version.
Stars: ✭ 57 (-90.85%)
Mutual labels:  crop-image, imagepicker
Cropme
Extremely Smooth and Easy Cropping library for you
Stars: ✭ 306 (-50.88%)
Mutual labels:  image, crop-image
Tkimageview
An easy way to crop an image.
Stars: ✭ 342 (-45.1%)
Mutual labels:  image, crop-image
XGImagePickerController
iOS相册图片/视频选择器
Stars: ✭ 32 (-94.86%)
Mutual labels:  camera, imagepicker
WAProfileImage
WAProfileImage - A library for Android for choosing and editing profile image like WhatsApp
Stars: ✭ 29 (-95.35%)
Mutual labels:  crop-image, imagepicker
MJMediaPicker
A Custom Class to select media from camera ,video or photo library by just adding a single file
Stars: ✭ 15 (-97.59%)
Mutual labels:  camera, imagepicker
Tocropviewcontroller
A view controller for iOS that allows users to crop portions of UIImage objects
Stars: ✭ 4,210 (+575.76%)
Mutual labels:  image, crop-image
Imagepicker
完全仿微信的图片选择,并且提供了多种图片加载接口,选择图片后可以旋转,可以裁剪成矩形或圆形,可以配置各种其他的参数
Stars: ✭ 4,225 (+578.17%)
Mutual labels:  imagepicker, image-picker
Cameraengine
🐒📷 Camera engine for iOS, written in Swift, above AVFoundation. 🐒
Stars: ✭ 554 (-11.08%)
Mutual labels:  camera, image
Album
🍉 Album and Gallery for Android platform.
Stars: ✭ 2,430 (+290.05%)
Mutual labels:  camera, image
SSImagePicker
Easy to use and configurable library to Pick an image from the Gallery or Capture an image using a Camera... 📸
Stars: ✭ 227 (-63.56%)
Mutual labels:  crop-image, imagepicker

📸Image Picker Library for Android

Download Releases API Language Android Arsenal PRWelcome Say Thanks! Twitter

Built with ❤︎ by Dhaval Patel and contributors

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.

🐱‍🏍Features:

  • 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 File, File Path as String or Uri object
  • Handle Runtime Permission for Camera and Storage

🎬Preview

Profile Image Picker Gallery Only Camera Only

💻Usage

  1. Gradle dependency:

    allprojects {
       repositories {
          	jcenter()
           	maven { url "https://jitpack.io" }  //Make sure to add this in your project for uCrop
       }
    }
    
    implementation 'com.github.dhaval2404:imagepicker:1.8'
    

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

    implementation 'com.github.dhaval2404:imagepicker-support:1.7.1'
    

    If you want to get the activity result inline in a modern way (lambda) install InlineActivityResult library:

    implementation 'com.github.florent37:inline-activity-result-kotlin:1.0.4'
    
  2. If you target Android 10 or higher(targetSdkVersion >= 29), set the value of requestLegacyExternalStorage to true in your app's manifest file:

    <manifest ... >
        <!-- This attribute is "false" by default on apps targeting
             Android 10 or higher. -->
        <application android:requestLegacyExternalStorage="true" ... >
          ...
        </application>
    </manifest>
    
  3. The ImagePicker configuration is created using the builder pattern.

    Kotlin

    ImagePicker.with(this)
            .crop()	    			//Crop image(Optional), Check Customization for more option
            .compress(1024)			//Final image size will be less than 1 MB(Optional)
            .maxResultSize(1080, 1080)	//Final image resolution will be less than 1080 x 1080(Optional)
            .start()
    

    Java

    ImagePicker.Companion.with(this)
            .crop()	    			//Crop image(Optional), Check Customization for more option
            .compress(1024)			//Final image size will be less than 1 MB(Optional)
            .maxResultSize(1080, 1080)	//Final image resolution will be less than 1080 x 1080(Optional)
            .start()
    
  4. Handling results

    Default method(Preferred way)
    Override onActivityResult method and handle ImagePicker result.

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
         super.onActivityResult(requestCode, resultCode, data)
         if (resultCode == Activity.RESULT_OK) {
             //Image Uri will not be null for RESULT_OK
             val fileUri = data?.data
             imgProfile.setImageURI(fileUri)
          
            //You can get File object from intent
            val file:File = ImagePicker.getFile(data)!!
           
            //You can also get File Path from intent
            val filePath:String = ImagePicker.getFilePath(data)!!
         } else if (resultCode == ImagePicker.RESULT_ERROR) {
             Toast.makeText(this, ImagePicker.getError(data), Toast.LENGTH_SHORT).show()
         } else {
             Toast.makeText(this, "Task Cancelled", Toast.LENGTH_SHORT).show()
         }
    }
    

    Inline method (with InlineActivityResult library, Only Works with FragmentActivity and AppCompatActivity) (Not to be used with crop. See #32)

    ImagePicker.with(this)
            .compress(1024)         //Final image size will be less than 1 MB(Optional)
            .maxResultSize(1080, 1080)  //Final image resolution will be less than 1080 x 1080(Optional)
            .start { resultCode, data ->
                if (resultCode == Activity.RESULT_OK) {
                    //Image Uri will not be null for RESULT_OK
                     val fileUri = data?.data
                     imgProfile.setImageURI(fileUri)
                  
                    //You can get File object from intent
                    val file:File = ImagePicker.getFile(data)
                   
                    //You can also get File Path from intent
                    val filePath:String = ImagePicker.getFilePath(data)
                } else if (resultCode == ImagePicker.RESULT_ERROR) {
                    Toast.makeText(context, ImagePicker.getError(data), Toast.LENGTH_SHORT).show()
                } else {
                    Toast.makeText(context, "Task Cancelled", Toast.LENGTH_SHORT).show()
                }
            }
    

🎨Customization

  • Pick image using Gallery

    ImagePicker.with(this)
    	.galleryOnly()	//User can only select image from Gallery
    	.start()	//Default Request Code is ImagePicker.REQUEST_CODE
    
  • Capture image using Camera

    ImagePicker.with(this)
    	.cameraOnly()	//User can only capture image using Camera
    	.start()
    
  • Crop image

    ImagePicker.with(this)
    	.crop()	    //Crop image and let user choose aspect ratio.
    	.start()
    
  • Crop image with fixed Aspect Ratio

    ImagePicker.with(this)
    	.crop(16f, 9f)	//Crop image with 16:9 aspect ratio
    	.start()
    
  • Crop square image(e.g for profile)

    ImagePicker.with(this)
        .cropSquare()	//Crop square image, its same as crop(1f, 1f)
        .start()
    
  • Compress image size(e.g image should be maximum 1 MB)

    ImagePicker.with(this)
    	.compress(1024)	//Final image size will be less than 1 MB
    	.start()
    
  • Set Resize image resolution

    ImagePicker.with(this)
    	.maxResultSize(620, 620)	//Final image resolution will be less than 620 x 620
    	.start()
    
  • Intercept ImageProvider, Can be used for analytics

    ImagePicker.with(this)
        .setImageProviderInterceptor { imageProvider -> //Intercept ImageProvider
            Log.d("ImagePicker", "Selected ImageProvider: "+imageProvider.name)
        }
        .start()
    
  • Intercept Dialog dismiss event

    ImagePicker.with(this)
    	.setDismissListener {
    		// Handle dismiss event
    		Log.d("ImagePicker", "onDismiss");
    	}
    	.start()
    
  • Specify Directory to store captured, cropped or compressed images

    ImagePicker.with(this)
        //Provide directory path to save images
        .saveDir(File(Environment.getExternalStorageDirectory(), "ImagePicker"))
        // .saveDir(Environment.getExternalStorageDirectory())
        // .saveDir(getExternalFilesDir(null)!!)
        .start()
    
  • Limit MIME types while choosing a gallery image

    ImagePicker.with(this)
        .galleryMimeTypes(  //Exclude gif images
            mimeTypes = arrayOf(
              "image/png",
              "image/jpg",
              "image/jpeg"
            )
          )
        .start()
    
  • You can also specify the request code with ImagePicker

    ImagePicker.with(this)
    	.maxResultSize(620, 620)
    	.start(101)	//Here 101 is request code, you may use this in onActivityResult
    
  • Add Following parameters in your colors.xml file, If you want to customize uCrop Activity.

    <resources>
        <!-- Here you can add color of your choice  -->
        <color name="ucrop_color_toolbar">@color/teal_500</color>
        <color name="ucrop_color_statusbar">@color/teal_700</color>
        <color name="ucrop_color_widget_active">@color/teal_500</color>
    </resources>
    

💥Compatibility

  • Library - Android Kitkat 4.4+ (API 19)
  • Sample - Android Kitkat 4.4+ (API 19)

✔️Changelog

Version: 1.8

  • 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

Version: 1.7

  • 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

Version: 1.6

  • 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

Version: 1.5

  • 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)

Version: 1.4

Version: 1.3

  • Sample app made compatible with Android Kitkat 4.4+ (API 19)
  • Fixed Uri to File Conversion issue #8 (Special Thanks to squeeish)

Version: 1.2

  • Added Support for Inline Activity Result(Special Thanks to soareseneves)
  • Fixed issue #6

Version: 1.1

  • Optimized Compression Logic
  • Replace white screen with transparent one.

Version: 1.0

  • Initial Build

📃 Libraries Used

Let us know!

We'll be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the library.

License

Copyright 2019-2020, Dhaval Patel

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].