jayrambhia / croppernocropper Goto Github PK
View Code? Open in Web Editor NEWInstagram Style Image Cropper for Android (Library)
Home Page: http://www.jayrambhia.com/project/nocropper-library
License: Apache License 2.0
Instagram Style Image Cropper for Android (Library)
Home Page: http://www.jayrambhia.com/project/nocropper-library
License: Apache License 2.0
How to force to imageview to not be reduced less than width and height of the CropperView at the same time? I have tried to use isMakeSquare and then setting up back to the initial position but it's not clear. Please help! I try too with setMinZoom(0)
Hi ,
Thanks for the awesome work on the library. I wish to use the same thing just like instagram does for multi image cropping, my use case is
please suggest if this thing is possible. I am short on time as well here , so would appriciate a quick response.
In v0.2.0 I'm not able to use getCroppedBitmap() method anymore. I'm getting the error that getCroppedBitmap() has a private access. How should I get the cropped bitmap now?
Thanks in advance
Anytime I try to crop a screenshot it throws that error ,pls what can I do
how get bitmap image after crop
Hi dear,
I was utilizing your great library "nocropper" for some of my need, i was working with the library on one of my PC where i get the Bitmap using getCroppedBitmap as " Bitmap bm = cropperView.getCroppedBitmap()", it went find and i got the resultant bitmap. But now i am working with the same library and code on my other PC where i get a weird error saying getCroppedBitmap returns BitmapResult so you have to get a BitmapResult and not a Bitmap. While i need a Bitmap so i can use it frther but I'm unable to get it. what could be the issue. can you please throw some light on it.
Set min zoom to 0.8f.
Take an image which is really long in height, i'm using the below image.
Issue seems to be in on up
private boolean onUp(){
...
if (showAnimation()) {
animateAdjustmentWithScale(tx, xx, ty, **ty,** scaleX, mMinZoom);
} else {
matrix.reset();
matrix.setScale(mMinZoom, mMinZoom);
matrix.postTranslate(xx, **ty**);
setImageMatrix(matrix);
invalidate();
if (DEBUG) {
Log.i(TAG, "scale after invalidate: " + getScale(matrix));
}
}
return true;
}
...
Should solve the issue,
when i set min zoom to suppose 1.25 of the height, it works fine on supporting minimum zoom but after minimum zooming, I cannot pan the image within the square. The image snaps back to the minimum zoom set with center aligned.
it seems your are calculating the CropperView based on the width of the view. Now the problem is I'm not able to make the view center in the screen.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_frame"
android:layout_alignParentTop="true" >
<com.fenchtose.nocropper.CropperView
android:background="#ff282828"
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:grid_opacity="0.8"
app:grid_thickness="1.1dp"
app:grid_color="@color/colorAccent"/>
<ImageView
android:id="@+id/snap_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="16dp"
android:padding="8dp"
android:layout_gravity="left|bottom"
android:background="@drawable/black_transp_circ_ripple"
android:scaleType="center"
android:src="@mipmap/ic_crop_free_white_24dp"/>
<ImageView
android:id="@+id/rotate_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:layout_margin="16dp"
android:layout_gravity="right|bottom"
android:background="@drawable/black_transp_circ_ripple"
android:scaleType="center"
android:src="@mipmap/ic_rotate_right_white_24dp"/>
</FrameLayout>
<LinearLayout
android:id="@+id/bottom_frame"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#ff212121"
android:padding="9dp"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Upload Image"
android:id="@+id/image_button"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Crop"
android:id="@+id/crop_button"/>
</LinearLayout>
</RelativeLayout>
Hi, thanks for great library. How can i change the size final image px. For example when i use square final image gives 720x720 , or when i crop rectangle height or width 720px. But i want to change this with 1280 or etc. How can i do? thank you.
we used implementation 'com.fenchtose.nocropper:nocropper:0.3.1' image rotate when we select image on samsung devices Samsung Galaxy A50 image rotate.
thank you very much
How can I set minimum zoom as per my Image width (For multiple Image selection)? Just like Instagram
Case 1: If I select a single image then Image should be zoom minimum as possible (Default).
Case 2: If I am selecting multiple Images then Images should be zoom minimum to image width (Just like cropToCenter()
).
I want to keep the grid lines always available, But i am not able to find any solution for that. Is there any solution to keep it visible all the time ?
HI the grid lines on the cropper imageview are not shown
does this support doupble tap to zoom?
CroppedBitmap also take black line which is not part of Image .
How to remove that black portion
It happens with most potrait Images.
BitmapResult bitmapResult = ivSelectedImage.getCroppedBitmap();
if (bitmapResult.getState() == CropState.SUCCESS) {
bitmapResult.getBitmap();
}
Thanks for Awesome work on NoCropper.
Really Amazing Library to Achieve decent crop function.
In last update it's introduce replaceBitmap() method , this is the thing that i was looking for.
After block "Bitmap is of different size. Not replacing" part in replaceBitmap method it's resize bitmap for the first time, then it's work fine.
how to make it work fine ? for all the time including very first time.
zoom not working inside the scrollview and the gesture not responding inside the scrollview/Nested scrollview
please find the below code: and also tested with CropperView also its not working the view is now just an image view. Not working in scroll sconatiner
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.fenchtose.nocropper.CropperImageView
android:id="@+id/cropper_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent_purple"
app:nocropper__grid_color="@color/colorAccent"
app:nocropper__grid_opacity="0.8"
app:nocropper__grid_thickness="0.8dp"
android:nestedScrollingEnabled="false"
app:nocropper__padding_color="@color/transparent_purple" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/snap_button"
android:layout_width="@dimen/margin_30"
android:layout_height="@dimen/margin_30"
android:layout_gravity="bottom|start"
android:layout_margin="@dimen/margin_20"
android:src="@drawable/ic_image_enlarge" />
</FrameLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
I have tried to get "bitmap" from CropperView like our regular android image-view.
In android, we get "bitmap" using the following line
BitmapDrawable drawable = (BitmapDrawable) iv_image.getDrawable(); Bitmap image = drawable.getBitmap();
I have tried same thing with CropperView but getDrawable() method is not working.
I want bitmap for the change its brightness. I get the bitmap from CropperView using Bitmap bitmap = mImageView.getCroppedBitmap(); but unable to change brightness for image-view using this bitmap.
OR Simple, please tell me how to change brightness for image-view using CropperView.
Hi,
Thanks for sharing this library.
I'm facing a issue in the following scenario,
For your ref, i added the code snipped what i had done,
public class BaseActivity extends Activity {
private static final int REQUEST_GALLERY = 21;
public static String imagePath = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_base);
findViewById(R.id.image_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startGalleryIntent();
}
});
findViewById(R.id.crop_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (!imagePath.isEmpty()) {
startActivity(new Intent(BaseActivity.this, MainActivity.class).putExtra("IMAGE_PATH", imagePath));
}
}
});
}
private void startGalleryIntent() {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, REQUEST_GALLERY);
}
@Override
public void onActivityResult(int requestCode, int responseCode, Intent resultIntent) {
super.onActivityResult(requestCode, responseCode, resultIntent);
if (responseCode == RESULT_OK) {
imagePath = BitmapUtils.getFilePathFromUri(this, resultIntent.getData());
// loadNewImage(absPath);
}
}
}
After enabling the progaurd in my project CropperNoCropper library is not working.
Its crashing and throwing the null pointer exception .
Can you please provide progaurd files which need to add in my project.
Thanks in advance
Hey there,
With the following configuration the CropperView still shows a grid view when moving the image even though the grid_color, thickness are set to make it transparant.
Is there a way to hide the grid lines when moving the image? For us this is not relevant since we don't try to align buildings and stuff :)
<com.fenchtose.nocropper.CropperView
android:id="@+id/userImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@color/white"
app:nocropper__grid_color="@android:color/transparent"
app:nocropper__grid_thickness="0dp"
app:nocropper__padding_color="@color/white" />
When not moving | when moving the image |
---|---|
![]() |
![]() |
Version 0.1.7 works as intented but after updating v0.2 I get this exception.
Fatal Exception: java.lang.IllegalArgumentException: y must be >= 0
at android.graphics.Bitmap.checkXYSign(Bitmap.java:366)
at android.graphics.Bitmap.createBitmap(Bitmap.java:683)
at com.fenchtose.nocropper.CropperImageView.getCroppedBitmap(SourceFile:861)
at com.fenchtose.nocropper.CropperImageView.cropBitmap(SourceFile:679)
at com.fenchtose.nocropper.CropperView.getCroppedBitmap(SourceFile:100)
On some devices, when I get image from gallery or camera intent, they are rotated in the crop view. I've tested it on LG G3 and Samsung Galaxy Note 3.
I'm ok with setMaxZoom, but unfortunately setMinZoom is not working!
Here is my code
// Set Bitmap cropperView.setImageBitmap(bitmap); // Set Max and Min Cropping cropperView.setMaxZoom(1.5f); cropperView.setMinZoom(0.8f);
Hi, thanks for the library it was cool and have the features i needed.
I was facing an issue found this in your sample app too.
When i was trying to crop the original image after setting the rotation it was not working.
pls check once and let me know any possible solution.
Note :
It was working with BitmapResult result = mImageView.getCroppedBitmap();
But not working when i try to crop the original image from this method prepareCropForOriginalImage();
from your sample
i want to crop minimum 800 X 1200 image size
what i do?
I tried to use the setPaddingColor(color) function for the CropperView but it isn't saving it with the padding color. However, if I set the padding color from the layout file, then it works.
So I looked in your code and in your function (in CropperView), setPaddingColor doesn't set the padding color for the mImageView.
On my side I just modified your code to fix it but just letting you know too. :)
With prescale enabled the cropping is working wrong.
thanks for the last update of removing the padding @jayrambhia, how can i set the max aspect ratio of the image while cropping?
Currently, the CropperView offsets the height based on width. This wouldn't work properly in landscape scenario. Add support for Landscape layout.
How to save crop state white cropping with multiple images ?
When we zoom the image in the CropperView and moves the image ...the image in the CropperView leaves the border and after this if we crop the image it gives this error....
java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
Hi @jayrambhia
Thanks for sharing this library.
It´s possible change the ratio of the crop frame?
Now its a square, but i need crop with a vertical rectangle form.
The output size now it´s 960x960, it´s possible change this too?¿
Thanks ind advanced :))
Sergio
Is there any possibility to avoid image to be zoomed initially to 1:1 instead of its real size f.e. 16:9?
@jayrambhia
Hello,
Yes, it's work fine when you wants to rotate bitmap with setBitmap(rotateBitmap(mOrigBitmap)), but when you scale image then do rotate, it's reassign bitmap to CropperView, so i like to use replaceBitmap(rotatedBitmap) for avoiding reassign bitmap, then i figured out it wan't rotate from center point as it has to.
How to get rid of this strange rotate behavior ?
Flow for this.
Desire result is rotatedBitmap should be replace with reference to center points of scaled bitmap with latest matrix.
can we show video in your image cropper section?
Does need to exclude getCroppedBitmap() to another thread?
It will simplify setting images via Glide
I did the following steps:
after that, it crashes.
update:
it will crash after i scale it smaller but not to fit center.
steps:
I have a problem in my CropperView, because the view Touch event don't prevent the ViewPager swipe, and this issue, makes it difficult to resize image.
Please let me know if there is any solution to calculate maxzoom for my desired dimensions ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.