百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

InstaCropper

> 编程语言
开源

与 Instagram 的收成相近的裁剪图像视图, 它允许一系列的侧面比, 而不是实相比 。 种植活动还包括:

375 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

与 Instagram 的收成相近的裁剪图像视图, 它允许一系列的侧面比, 而不是实相比 。 种植活动还包括:

NOTICE: I build custom views "for free". Just send me a description of what you need and I will send it to you the next day! Email me at yasharpm[at]gmail[dot]com with the subject "CustomView request".

InstaCropper

A View for cropping images that is similar to Instagram's crop. Also an Activity for cropping is included.

Usage

Add the dependency:

groovy
dependencies {
	implementation 'com.yashoid:instacropper:1.2.0'
}

How to use this library

Add InstaCropperView to your xml layout

xml

    

InstaCropperView receives only Uri but any Uri is possible.

java
mInstaCropper.setImageUri(imageUri);

You can specify three size ratios for the crop. The narrowest allowed, the widest allowed and the ideal ratio. The View will adjust its size by the ideal ratio.

java
mInstaCropper.setRatios(defaultRatio, minimumRatio, maximumRatio);

The cropped image is returned in a callback. You can specify MeasureSpec to adjust the width and height of the returned Bitmap.

java
mInstaCropper.crop(
        View.MeasureSpec.makeMeasureSpec(1024, View.MeasureSpec.AT_MOST),
        View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
        new InstaCropperView.BitmapCallback() {

            @Override
            public void onBitmapReady(Bitmap bitmap) {
                // Do something.
            }
            
        }
);

It is also possible to use the crop feature via an Intent call. There are various getIntent() methods defined on InstaCropperActivity. You will then receive the crop result in data.getData().

java
Intent intent = InstaCropperActivity.getIntent(context, srcUri, dstUri, maxWidth, outputQuality);
startActivityForResult(intent, REQUEST_CROP);

Cropping of multiple images is also possible. Use MultipleCropActivity.getIntent() methods to access. If all the images are cropped you will receive RESULT_OK otherwise RESULT_CANCELED. EXTRA_COUNT will contain the number of images cropped.

java
Intent intent = MultipleCropActivity.getIntent(context, srcUris, dstUris, maxWidth, maxHeight, aspectRatio);
startActivityForResult(intent, REQUEST_MULTIPLE_CROP);

You can modify the crop Activity's apprearance by overriding the following resouce values:

xml
Crop 
Crop 

@android:color/white 
@android:color/black 

 

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言