Code Monkey home page Code Monkey logo

ngcroppie's Introduction

ngCroppie - Angular Croppie Tool

What Am I?!

An awesome image cropping and rotating module for AngularJS based on Croppie.js
Pure Javascript implementation; Also responsive!

Live Demo

Check it out

Install

NPM: npm install ng-croppie

Bower: bower install ngCroppie

Download: ng-croppie.js and ng-croppie.css

Ensure you link it correctly in your HTML

<script src="path/to/ng-croppie.min.js"></script>
<link rel='stylesheet' type="text/css" href="path/to/ng-croppie.min.css"></link>

And add it as a module for your app:

var app = angular.module('myApp', ['ngCroppie']);

Nothing is required in the controller. For sake of clarity, these are the variables you'll see in the demo.

    app.controller('basicController', ['$scope', function($scope) {

            $scope.inputImage = null;
            $scope.outputImage = null;
            $scope.onUpdate = function(data) {
                //console.log(data)
            }
    }]);

Now, just add it to your HTML.

<!-- Bare minimum -->
<ng-croppie   src="inputImage"
              ng-model='outputImage'>
</ng-croppie>



<!-- With options -->
<ng-croppie   src="inputImage"
              ng-model='outputImage'
              update='onUpdate'
              boundry="{w: 400, h: 400}"
              viewport="{w: 300, h: 300}"
              orientation="true"
              rotation="90"  <!-- rotatation to 90 degrees -->
              type="circle">
</ng-croppie>



<!-- Preview -->
<img  ng-src="{{outputImage}}" />

Parameters

src: [path/to/image.js] OR base64. 
ng-model: The image output. Returns are a base64. 
update: [function] place a functon in the controller to run whenever changes are made to the image. 
boundry: [object] {w: __, h: __}. This will create the size of the container that will host the Croppie tool. Not required, but will default to 300x300. 
viewport: [object] {w: __, h: __}. This will create your output size. Must be smaller than the boundry or it will equal it. Defaults to 200x200. 
zoom: [Boolean] Set to true by default, which shows the zoom slider. Not required; defaults to true.
mousezoom: [Boolean] Enables to use the mouse scroll bar to zoom in/out. Works with 'zoom' true; defaults to true.
zoomslider: [Boolean] Hide or Show the zoom slider only (scrolling and pinching zoom still possible if set to false). Works with 'zoom' true; defaults to true.
exif: [Boolean] with exif orientation compatability. Not required; defaults to undefined.
orientation: [Boolean] Support for specifying a custom orientation when binding images. Not required; defaults to false.
rotation: [Integer] Rotate the image by a specified degree amount. Only works with 'orientation' true. Not required; Valid values: 90, 180, 270, -90, -180, -270
type: [String] Can either be "circle" or "square". Not required; defaults to "square". 

Version

1.0.1

Contributors

  • orif-jr
  • stasinua
  • htao00
  • alanheppenstall

Updates

  • added Croppie.js as library dependencies
  • modularized the code structure
  • reorganized files location
  • code refactoring

Dependencies

None, just Angular 1.4+

License

MIT - go nuts y'all.

ngcroppie's People

Contributors

orifn avatar allenjynroyston avatar alanheppenstall avatar htao00 avatar stasinua avatar

Watchers

Mark Somerville avatar Colin Gemmell avatar James Cloos avatar David McAdam avatar Ricky Dalziel avatar Teng Li avatar Stephen Edgar avatar Paul Hornsey avatar  avatar  avatar

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.