All Projects → wildma → Pictureselector

wildma / Pictureselector

Licence: apache-2.0
🔥 Android 图片选择器(仿 IOS 图片选择控件)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Pictureselector

Imagepicker
Android下的图片选择与裁剪开源库(android image picker and cropper library)
Stars: ✭ 223 (-22.3%)
Mutual labels:  image-cropper, image-picker
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 (-91.29%)
Mutual labels:  image-picker
Croppie
A Javascript Image Cropper
Stars: ✭ 2,330 (+711.85%)
Mutual labels:  image-cropper
vcrop
A simple Vue image cropping component.
Stars: ✭ 14 (-95.12%)
Mutual labels:  image-cropper
Daguerre
Local image and video selector for Android
Stars: ✭ 33 (-88.5%)
Mutual labels:  image-picker
angular-croppie
Angular 1.5+ Component for Croppie
Stars: ✭ 16 (-94.43%)
Mutual labels:  image-cropper
Faimagecropper
Image Cropper like Instagram
Stars: ✭ 188 (-34.49%)
Mutual labels:  image-cropper
Abra
Your next favorite image and video picker from Gallery for Swift
Stars: ✭ 19 (-93.38%)
Mutual labels:  image-picker
ConvenientImagePicker
🏞🌅🌄🎇🌇🏙🌃🌉🌁the new iOS image picker. Beautiful, delicate, and customizable.
Stars: ✭ 44 (-84.67%)
Mutual labels:  image-picker
xcrop
Mobile image cropping component - Vue React 移动端裁剪组件
Stars: ✭ 27 (-90.59%)
Mutual labels:  image-cropper
advance image picker
Flutter plugin for selecting multiple images from the Android and iOS image library, taking new pictures with the camera, and edit them before using such as rotating, cropping, adding sticker/filters.
Stars: ✭ 91 (-68.29%)
Mutual labels:  image-picker
image-picka
A Firefox/Chrome extension helping you download images.
Stars: ✭ 114 (-60.28%)
Mutual labels:  image-picker
ionic3-image-handling
In this ionic tutorial you will learn how to access the image gallery and take pictures from an ionic app. Also we will show you how to add a image cropper. This ionic tutorial includes a working ionic app example you can reuse for your needs.
Stars: ✭ 35 (-87.8%)
Mutual labels:  image-cropper
Antd Img Crop
🔪 An image cropper for Ant Design Upload
Stars: ✭ 207 (-27.87%)
Mutual labels:  image-cropper
vue-slim-cropper
💇‍♀️ A simple and elegant mobile image crop upload component for Vue 2.x | 简洁易用的 vue 移动端图片裁剪上传组件
Stars: ✭ 34 (-88.15%)
Mutual labels:  image-cropper
Cropiwa
📐 Configurable Custom Crop widget for Android
Stars: ✭ 2,185 (+661.32%)
Mutual labels:  image-cropper
tinycrop
Pure JavaScript image crop library
Stars: ✭ 62 (-78.4%)
Mutual labels:  image-cropper
Mantis
A photo cropping tool which mimics Photo.app written by Swift.
Stars: ✭ 270 (-5.92%)
Mutual labels:  image-cropper
ChatViewController
💬 ChatViewController, ChatBar, ImagePicker like Slack Application. Message App written in Swift
Stars: ✭ 47 (-83.62%)
Mutual labels:  image-picker
image picker flutter
ImagePicker
Stars: ✭ 27 (-90.59%)
Mutual labels:  image-picker

PictureSelector

Android 图片选择器(仿 IOS 图片选择控件)

效果图

效果图.jpg

功能特点

  • 支持通过拍照获取图片
  • 支持通过相册获取图片
  • 支持图片是否裁剪两种场景
  • 支持仿 IOS 底部弹出选择菜单 ActionSheet 效果
  • 适配 Android Q 版本

使用

Step 1. 添加 JitPack 仓库

在项目的 build.gradle 添加 JitPack 仓库

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

Step 2. 添加依赖

在需要使用的 module 中添加依赖
注意:从 2.0.0 版本开始,项目迁移到 AndroidX。如果你的项目还未迁移到 AndroidX,可以使用 1.2.0 版本。

dependencies {
	implementation 'com.github.wildma:PictureSelector:2.1.0'
}

Step 3. 拍照或者从相册选择图片

使用场景:

  • 不裁剪
PictureSelector
        .create(MainActivity.this, PictureSelector.SELECT_REQUEST_CODE)
        .selectPicture(false);
  • 自由裁剪
PictureSelector
        .create(MainActivity.this, PictureSelector.SELECT_REQUEST_CODE)
        .selectPicture(true);
  • 指定宽高及宽高比例裁剪
PictureSelector
        .create(MainActivity.this, PictureSelector.SELECT_REQUEST_CODE)
        .selectPicture(true, 200, 200, 1, 1);

参数解释:

  • create():参数一是上下文,在 activity 中传 activity.this,在 fragment 中传 fragment.this。参数二是请求码,用于结果回调 onActivityResult() 中判断。
  • selectPicture():参数分别为是否裁剪、裁剪后图片的宽(单位 px)、裁剪后图片的高、宽比例、高比例。

Step 4. 获取图片地址进行显示

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        /*结果回调*/
        if (requestCode == PictureSelector.SELECT_REQUEST_CODE) {
            if (data != null) {
                PictureBean pictureBean = data.getParcelableExtra(PictureSelector.PICTURE_RESULT);
                if (pictureBean.isCut()) {
                    mIvImage.setImageBitmap(BitmapFactory.decodeFile(pictureBean.getPath()));
                } else {
                    mIvImage.setImageURI(pictureBean.getUri());
                }

                //使用 Glide 加载图片
                /*Glide.with(this)
                        .load(pictureBean.isCut() ? pictureBean.getPath() : pictureBean.getUri())
                        .apply(RequestOptions.centerCropTransform()).into(mIvImage);*/
            }
        }
    }

清理缓存

实际开发中将图片上传到服务器成功后需要删除全部缓存图片(即裁剪后的无用图片),调用如下方法即可:

    FileUtils.deleteAllCacheImage(this);

注意

如果你没有使用依赖的方式,而是直接拷贝源码到你的项目中使用。那么需要自己适配 Android 7.0 导致的 FileUriExposedException 异常,具体方式如下:

将 PictureSelectUtils 中的 authority 与你项目中 AndroidManifest.xml 下的 authority 保持一致。 例如 AndroidManifest.xml 下的 authority 为:

android:authorities="myAuthority"

则需要修改 PictureSelectUtils 中的 authority( 这一行) 为:

String authority = "myAuthority";

详细介绍请看文章:一个非常好用的 Android 图片选择框架

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].