https://github.com/hansemannn/titanium-image-crop
An easy to use iOS image cropping tool based on TOCropViewController.
https://github.com/hansemannn/titanium-image-crop
appcelerator image-cropping javascript native titanium
Last synced: about 1 year ago
JSON representation
An easy to use iOS image cropping tool based on TOCropViewController.
- Host: GitHub
- URL: https://github.com/hansemannn/titanium-image-crop
- Owner: hansemannn
- License: mit
- Created: 2019-03-14T10:38:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-11T13:11:32.000Z (over 4 years ago)
- Last Synced: 2025-03-29T01:12:03.634Z (about 1 year ago)
- Topics: appcelerator, image-cropping, javascript, native, titanium
- Language: Objective-C
- Size: 17.6 MB
- Stars: 40
- Watchers: 6
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Titanium Image Cropping Tool
An easy to crop images to different scales. Based on the awesome [TOCropViewController](https://github.com/TimOliver/TOCropViewController) library. Currently iOS only (!)

## Requirements
- [x] Titanium SDK 9.2.0+ (this module is 100 % Swift based)
## Methods
### `showCropDialog`
#### Parameters
- `image` (String, Ti.Blob, Ti.File)
- `croppingStyle` 'circular' or 'default' (String) in not set 'default' is selected
- `aspectRatio` (either a dictionary {x, y} of the ratio or one of the constants * below)
## Constants
- `ASPECT_RATIO_SQUARE`
- `ASPECT_RATIO_3x2`
- `ASPECT_RATIO_5x3`
- `ASPECT_RATIO_4x3`
- `ASPECT_RATIO_5x4`
- `ASPECT_RATIO_7x5`
- `ASPECT_RATIO_16x9`
## Events
- `done`
- Attributes: `image` (Ti.Blob, if finished cropping), `cancel` (`true` if cancelled, `false` if completetd)
- `close`
## Notes
- If opening the image crop dialog from a modal window, please set the `modalStyle: Ti.UI.iOS.MODAL_PRESENTATION_OVER_CURRENT_FULL_SCREEN` property (thanks to [designbymind](https://github.com/designbymind)!)
## Example
```js
import ImageCrop from 'ti.imagecrop';
ImageCrop.addEventListener('done', event => {
if (event.cancel) {
return;
}
win.add(Ti.UI.createImageView({ height: 400, image: event.image }));
});
ImageCrop.addEventListener('close', event => {
// Open other windows after the close has been triggered
// to prevent transition glitches
});
const win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
const btn = Ti.UI.createButton({
title: 'Show crop dialog'
});
btn.addEventListener('click', () => {
ImageCrop.showCropDialog({
image: 'test.jpg'
});
});
win.add(btn);
win.open();
```
## License
MIT
## Author
Hans Knöchel