PhotoEditor icon indicating copy to clipboard operation
PhotoEditor copied to clipboard

Crop

Open sepehr1014 opened this issue 6 years ago • 15 comments

Thank you for this awesome project. You mentioned cropping functionality is next. Is it in active development? What's the expected time frame?

sepehr1014 avatar Aug 14 '18 13:08 sepehr1014

Crop selection will be added in future release. But for time being you can crop the image using CustomEffect.Builder() which is a wrapper on EffectFacotory check this link.

burhanrashid52 avatar Aug 17 '18 12:08 burhanrashid52

Thanks but having crop selection would be great. I personally think it's a must for any photo editor.

sepehr1014 avatar Aug 30 '18 10:08 sepehr1014

U think when can you add this future?

DHosseiny avatar Oct 09 '18 12:10 DHosseiny

I don't have ETA for it. Currently, my schedule is a little tight this time. If anyone is able to do it before me than PR's are welcome

burhanrashid52 avatar Oct 09 '18 14:10 burhanrashid52

would donation make this feature available :) ?

animestanley avatar Nov 18 '18 15:11 animestanley

Donations are always welcome :) @animestanley

burhanrashid52 avatar Dec 04 '18 05:12 burhanrashid52

any updates about crop feature? :)

efreim avatar Sep 30 '19 10:09 efreim

If anyone is able to do it before me than PR's are welcome

@burhanrashid52 do you have an example of cropping you are using for reference?

lucianocheng avatar Dec 31 '19 01:12 lucianocheng

@lucianocheng https://github.com/siwangqishiq/ImageEditor-Android/blob/master/imageeditlibrary/src/main/java/com/xinlan/imageeditlibrary/editimage/fragment/CropFragment.java I am trying to implement into this branch https://github.com/burhanrashid52/PhotoEditor/tree/PE-79 with better API. But still not happy with the result.

burhanrashid52 avatar Jan 06 '20 04:01 burhanrashid52

Tried this library Android Image Cropper

Rect cropRect = imageCropView.getCropRect()
CustomEffect customEffect = new CustomEffect.Builder(EffectFactory.EFFECT_CROP)
                        .setParameter("xorigin", cropRect.left)
                        .setParameter("yorigin", cropRect.right)
                        .setParameter("width", cropRect.width())
                        .setParameter("height", cropRect.height())
                        .build();
                photoEditor.setFilterEffect(customEffect);

But its not cropping correctly. tried both imageCropView.getCropRect() and imageCropView.getCropWindowRect()

I think i need the width and height of your FilterImageView

EDIT: finally managed it to get working. But another problem is after cropping the image. the PhotoEditorView shows stretched image.

akhilakhi84 avatar Feb 01 '20 15:02 akhilakhi84

@akhilakhi84 can you please elaborate what you did and if you managed to make it work?

amitkle avatar May 25 '20 10:05 amitkle

For those following this: If your use case is to only crop the image once, before it is loaded, I was able to get this working with uCrop. The solution is blunt: Just crop the incoming image before loading it into the PhotoEditor.

The tricky part about solving this is cropping after the image has stickers, text, etc on it. All the things I've tried involve adding additional layers to the canvas, which isn't great. Also cropping with rotation is a whole other dimension. I don't have a solution I like yet.

lucianocheng avatar Apr 26 '21 05:04 lucianocheng

For me if could manage get photoeditor source and implement fragment dialog to crop image and replace back the image is better.

hafiz013 avatar Jan 26 '22 08:01 hafiz013

If we can get photoeditorview source then we can crop image..After highlighting image or writing text we cannot get edited image to crop.. How to get edited image??

sahil0289 avatar Mar 17 '22 08:03 sahil0289