Git Product home page Git Product logo

angular-crop-my-image's Introduction

Angular Crop My Image

Requirements

  • Modern Browser supporting <canvas>

Installing

Download

Or

  • Install with Bower
bower install angular-crop-my-image

Add dependency

Add the image cropper module as a dependancy to your application module:

angular.module('myApp', ['angular-crop-my-image']);

Options

Parameter Description
crop-width The width of the crop area
crop-height The height of the crop area
image The source image to crop
cropped-image The cropped image
keep-aspect Enforces that the aspect ratio is kept when dragging the crop area. The aspect ratio is defined by the width and height paramater.
touch-radius The radius for detecting touches/clicks on the corner drag markers and the centre drag marker.
crop-area-bounds (optional) A model that will be automatically updated with the bounds (left, right, top, bottom) of the crop area relative to the original source image.
min-width (optional) The minimum width that the crop area can be set to.
min-height (optional) The minimum height that the crop area can be set to.

Example usage

Markup example

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
<script src="angular-crop-my-image.min.js"></script>
<script>
    angular.module('myApp', ['angular-crop-my-image']);
    
    angular.module('myApp').controller("ImageCropperCtrl",[ '$scope', function($scope) 
    {
        $scope.cropper = {};
        $scope.cropper.sourceImage = null;
        $scope.cropper.croppedImage   = null;
        $scope.bounds = {};
        $scope.bounds.left = 0;
        $scope.bounds.right = 0;
        $scope.bounds.top = 0;
        $scope.bounds.bottom = 0;
    }]);
</script>
<meta charset="utf-8">
<title>Example</title>
</head>
<body ng-app="myApp">
    <div ng-controller="ImageCropperCtrl as ctrl">
        <input type="file" img-cropper-fileread image="cropper.sourceImage" />
        <div>
             <canvas width="500" height="300" id="canvas" image-cropper image="cropper.sourceImage" cropped-image="cropper.croppedImage" crop-width="400" crop-height="200" keep-aspect="true" touch-radius="30" crop-area-bounds="bounds"></canvas>
        </div>
        <div>Cropped Image (Left: {{bounds.left}} Right: {{bounds.right}} Top: {{bounds.top}} Bottom: {{bounds.bottom}})</div>
        <div ng-show="cropper.croppedImage!=null"><img ng-src="{{cropper.croppedImage}}" /></div>
    </div>
</body>
</html>

License

See the LICENSE file.

angular-crop-my-image's People

Watchers

James Cloos avatar Denis Stoliarchuk avatar

Forkers

vadimerm

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.