All Projects → steelkiwi → Cropiwa

steelkiwi / Cropiwa

📐 Configurable Custom Crop widget for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Cropiwa

Flutter image cropper
A Flutter plugin for Android and iOS supports cropping images
Stars: ✭ 723 (-66.91%)
Mutual labels:  image, crop, photo, image-cropper
react-drop-n-crop
An opinionated implementation of react-dropzone and react-cropper
Stars: ✭ 17 (-99.22%)
Mutual labels:  crop, cropper, crop-image, image-cropper
Rskimagecropper
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
Stars: ✭ 2,371 (+8.51%)
Mutual labels:  image, crop, photo, cropper
Tkimageview
An easy way to crop an image.
Stars: ✭ 342 (-84.35%)
Mutual labels:  image, crop, photo, crop-image
Tocropviewcontroller
A view controller for iOS that allows users to crop portions of UIImage objects
Stars: ✭ 4,210 (+92.68%)
Mutual labels:  image, crop, crop-image, cropper
Ucrop
Image Cropping Library for Android
Stars: ✭ 11,003 (+403.57%)
Mutual labels:  image, crop, photo
Croppr.js
A vanilla JavaScript image cropper that's lightweight, awesome, and has absolutely zero dependencies.
Stars: ✭ 294 (-86.54%)
Mutual labels:  image, crop, cropper
Cropme
Extremely Smooth and Easy Cropping library for you
Stars: ✭ 306 (-86%)
Mutual labels:  image, crop-image, cropper
react-simple-crop
✂️ A React component library for cropping and previewing images
Stars: ✭ 19 (-99.13%)
Mutual labels:  crop, cropper, crop-image
Resizer
An image resizing library for Android
Stars: ✭ 406 (-81.42%)
Mutual labels:  image, photo, photo-editing
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (-65.13%)
Mutual labels:  image, crop, crop-image
Photoflare
Quick, simple but powerful Cross Platform image editor.
Stars: ✭ 260 (-88.1%)
Mutual labels:  crop, photo, photo-editing
pikaso
Seamless and headless HTML5 Canvas library
Stars: ✭ 23 (-98.95%)
Mutual labels:  crop, cropper, crop-image
xcrop
Mobile image cropping component - Vue React 移动端裁剪组件
Stars: ✭ 27 (-98.76%)
Mutual labels:  cropper, crop-image, image-cropper
Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (-36.2%)
Mutual labels:  image, crop, crop-image
Smartcircle
✂️Automatically determine where to crop a circular image out of a rectangular.
Stars: ✭ 29 (-98.67%)
Mutual labels:  image, crop, crop-image
React Cropper
Cropperjs as React component
Stars: ✭ 1,600 (-26.77%)
Mutual labels:  crop, crop-image, cropper
Igrphototweaks
Drag, Rotate, Scale and Crop
Stars: ✭ 212 (-90.3%)
Mutual labels:  image, crop, crop-image
Ddperspectivetransform
🔲 Warp image transformation
Stars: ✭ 186 (-91.49%)
Mutual labels:  image, crop, photo
Croppy
Image Cropping Library for Android
Stars: ✭ 906 (-58.54%)
Mutual labels:  crop, crop-image, cropper

CropIwa

Made in SteelKiwi Android Arsenal

The library is a highly configurable widget for image cropping.

GifSample1

Gradle

Add this into your dependencies block.

compile 'com.steelkiwi:cropiwa:1.0.3'

Sample

Please see the sample app for library usage examples.

Wiki

The library has a modular architecture, which makes it highly configurable. For info on how to configure CropIwaView refer to the sections below.

One of the useful features is that you don't have to wait for a result - after crop request is done, simply switch to another screen and wait for the result in a form of broadcast.

Usage:

Add CropIwa to your xml:

<com.steelkiwi.cropiwa.CropIwaView
  android:id="@+id/crop_view"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />

Image saving

cropView.crop(new CropIwaSaveConfig.Builder(destinationUri)
  .setCompressFormat(Bitmap.CompressFormat.PNG)
  .setSize(outWidth, outHeight) //Optional. If not specified, SRC dimensions will be used
  .setQuality(100) //Hint for lossy compression formats
  .build());

Callbacks

Cropped region saved callback. When crop request completes, a broadcast is sent. You can either listen to it using the CropIwaView intance

cropView.setCropSaveCompleteListener(bitmapUri -> {
  //Do something
});

cropView.setErrorListener(error -> {
  //Do something
});

or work directly with a broadcast receiver. The advantage is that it can be used from any part of the app, where you have an access to Context.

CropIwaResultReceiver resultReceiver = new CropIwaResultReceiver();
resultReceiver.setListener(resultListener);
resultReceiver.register(context);

//Don't forget to unregister it when you are done
resultReceiver.unregister(context);

You can subscribe for changes in CropIwaViews configs. Listeners will be notified anytime .apply() is called.

cropIwaView.configureOverlay().addConfigChangeListener(listener);
cropIwaView.configureImage().addConfigChangeListener(listener)

Basic View Configuration

  • Enable user to resize a crop area. Default is true.
app:ci_dynamic_aspect_ratio="true|false"

cropView.configureOverlay()
  .setDynamicCrop(enabled)
  .apply();
  • Draw a 3x3 grid. Default is true.
app:ci_draw_grid="true|false"

cropView.configureOverlay()
  .setShouldDrawGrid(draw)
  .apply();
  • Set an initial crop area's aspect ratio.
app:ci_aspect_ratio_w="16"
app:ci_aspect_ratio_h="9"

cropView.configureOverlay()
  .setAspectRatio(new AspectRatio(16, 9))
  .setAspectRatio(AspectRatio.IMG_SRC) //If you want crop area to be equal to the dimensions of an image
  .apply();
  • Initial image position. Behavior is similar to ImageView's scaleType.
app:ci_initial_position="centerCrop|centerInside"

cropView.configureImage()
  .setImageInitialPosition(position)
  .apply();
  • Set current scale of the image.
//Value is a float from 0.01f to 1
cropIwaView.configureImage()
  .setScale(scale)
  .apply();
  • Enable pinch gesture to scale an image.
app:ci_scale_enabled="true|false"

cropView.configureImage()
  .setImageScaleEnabled(enabled)
  .apply();
  • Enable finger drag to translate an image.
app:ci_translation_enabled="true|false"

cropView.configureImage()
  .setImageTranslationEnabled(enabled)
  .apply();
  • Choosing from default crop area shapes. Default is rectangle.
app:ci_crop_shape="rectangle|oval"

cropView.configureOverlay()
  .setCropShape(new CropIwaRectShape(cropView.configureOverlay()))
  .setCropShape(new CropIwaOvalShape(cropView.configureOverlay()))
  .apply();
  • You can set a min-max scale. Default min is 0.7, default max is 3.
app:ci_max_scale="1f"

cropView.configureImage()
  .setMinScale(minScale)
  .setMaxScale(maxScale)
  .apply();
  • Crop area min size.
app:ci_min_crop_width="40dp"
app:ci_min_crop_height="40dp"

cropView.configureOverlay()
  .setMinWidth(dps)
  .setMinHeight(dps)
  .apply();
  • Dimensions.
app:ci_border_width="1dp"
app:ci_corner_width="1dp"
app:ci_grid_width="1dp"

cropView.configureOverlay()
  .setBorderStrokeWidth(dps)
  .setCornerStrokeWidth(dps)
  .setGridStrokeWidth(dps)
  .apply();
  • Colors.
app:ci_border_color="#fff"
app:ci_corner_color="#fff"
app:ci_grid_color="#fff"
app:ci_overlay_color="#fff"

cropView.configureOverlay()
  .setBorderColor(Color.WHITE)
  .setCornerColor(Color.WHITE)
  .setGridColor(Color.WHITE)
  .setOverlayColor(Color.WHITE)
  .apply();

Advanced View Configuration

You can work directly with Paint objects. This gives you an ability, for example, to draw a grid with dashed effect.

Paint gridPaint = cropView.configureOverlay()
  .getCropShape()
  .getGridPaint();
gridPaint.setPathEffect(new DashPathEffect(new float[] {interval, interval}, 0));

You can obtain other Paints in the same way.

CropIwaOverlayConfig config = cropView.configureOverlay();
CropIwaShape shape = config.getCropShape();
shape.getGridPaint();
shape.getBorderPaint();
shape.getCornerPaint();

You can also create custom crop area shapes. Just extend CropIwaShape (for an example refer to CropIwaOvalShape) and set an instance of you class using:

cropView.configureOverlay()
  .setCropShape(new MyAwesomeShape())
  .apply();

License

Copyright © 2017 SteelKiwi, http://steelkiwi.com

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