Coder Social home page Coder Social logo

hansemannn / titanium-image-crop Goto Github PK

View Code? Open in Web Editor NEW
40.0 6.0 5.0 18.01 MB

An easy to use iOS image cropping tool based on TOCropViewController.

License: MIT License

JavaScript 1.34% Objective-C 94.29% Swift 4.38%
titanium appcelerator image-cropping native javascript

titanium-image-crop's Introduction

Titanium Image Cropping Tool

An easy to crop images to different scales. Based on the awesome TOCropViewController library. Currently iOS only (!)

Example Screenshot

Example Screenshot rounded cropping

Requirements

  • 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!)

Example

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

titanium-image-crop's People

Contributors

hansemannn avatar mbender74 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

titanium-image-crop's Issues

StatusBar Styling

iOS 17+ automatically updates the StatusBar color according to the contrast beneath. This is the default functionality of the default styling option. This is great as it removes the headache of needing to update the StatusBar each time the developer wants to use a lighter/darker background. — More info here.

When completing an image crop and after the image crop controller is hidden, the StatusBar continues to use the lightContent option. — Is there anyway to change that functionality (to use the default option) or provide a way to set the StatusBar styling by passing a property to module?

ImageCrop dialog opens only once

First off, this is an awesome module, Thank You for open sourcing =]

After successfully showing the ImageCrop dialog, then clicking the "Cancel" button, then attempting to show the ImageCrop dialog again, nothing happens (no dialog shows, no error thrown).

Any idea why the above is happening? — Possibly something to do with the ImageCrop not being able to take the position as topPresentedController?

Side Note: when attempting to open ImageCrop directly after selecting an image from Photo Gallery (in the success callback of Ti.Media.openPhotoGallery), ImageCrop will not display without a setTimeout. — Possibly a race condition for the topPresentedController?

TiSDK: 10.1.0.v20210806050748
iOS: 14.5

Closes Modal

If ImageCrop is opened within (over) a Modal Window, it closes said modal after done or cancel events are called & app becomes unresponsive.

App crashes in startup

When trying to run the app, which works perfectly with XCode 11.5 and Ti SDK 8.3.1 or 9.0.2, with this module the app crashes immediatly on startup.

Operating System
Name = Mac OS X
Version = 10.15.5
Architecture = 64bit

CPUs = 6

Memory = 51539607552
Node.js
Node.js Version = 10.19.0
npm Version = 6.14.2
Titanium CLI
CLI Version = 5.2.2
Titanium SDK
SDK Version = 9.0.0.GA
SDK Path = /Users/marco/Library/Application Support/Titanium/mobilesdk/osx/9.0.0.GA
Target Platform = iphone

I tried to recompile the module but this didn´t work due to the old Swift 3 version.
Then i tried to update the sources to Swift 4 with Xcode 10.1 but this crashes as well with missing TitaniumKit.

Sorry to bother, but I need yourt help.
Thanks in advance

App with example crashes

Hello Hans,
I'm trying newest version and it keeps crashing when I'm using example code(so using example.jpg as image), without any log message.
I can however use it using file handler and it works almost perfect.
For first time run, it cropps as expected. for second time, done event is called twice, for third run, callback is called three times and so on. I cleanup my controller after window closes, no difference.
Please help.
Tested with Ti SDK 10.1.0.GA, iPhone 11 [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.