An easy to crop images to different scales. Based on the awesome TOCropViewController library. Currently iOS only (!)
showCropDialog
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)
ASPECT_RATIO_SQUARE
ASPECT_RATIO_3x2
ASPECT_RATIO_5x3
ASPECT_RATIO_4x3
ASPECT_RATIO_5x4
ASPECT_RATIO_7x5
ASPECT_RATIO_16x9
done
image
(Ti.Blob, if finished cropping), cancel
(true
if cancelled, false
if completetd)close
modalStyle: Ti.UI.iOS.MODAL_PRESENTATION_OVER_CURRENT_FULL_SCREEN
property (thanks to designbymind!)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();
MIT
Hans Knöchel