GithubHelp home page GithubHelp logo

hhy5277 / angular-image-crop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andyshora/angular-image-crop

0.0 1.0 0.0 306 KB

A better way to crop images client-side using AngularJS

Home Page: http://andyshora.com/angular-image-cropper.html

CSS 3.19% JavaScript 82.45% HTML 14.36%

angular-image-crop's Introduction

Angular Image Crop

I'm attempting to make a self-contained AngularJS Directive which will allow you to crop an image before it's uploaded to the server.

Features

  • Touch support, swipe to move and drag handle to zoom - see known issues
  • Add any image file from your device/machine
  • Output as a base64-encoded data uri
  • Uses HTML5 Canvas to display image in a flexible context, to allow dragging and zooming.
  • Note that regardless of the shape of the cropping guideline, resulting images will be square. For example, using the 'circle' shape parameter will show a circular guide, but the resulting images will have to be masked when rendering to the user.

Browser Support

  • IE10+, Android 3+, iOS 6+, basically all modern browsers!

Usage

  1. Add the dependency : angular.module('myApp',['ImageCropper'])
  2. Include the stylesheet
  3. Initiatlise the directive see standalone JSBin for example code.

Parameters

  • width (string) - the width of the cropper
  • height (string) - the height of the cropper
  • padding (integer) - space, in pixels, rounding the shape
  • max-size (integer) - max size of the image, in pixels
  • shape (string) - the cropping guideline shape (circle/square)
  • step (bound integer) - the variable which dictates which step the user will see (used for resetting purposes)
  • src (bound Blob or base64 string) - scope variable that will be the source image for the crop
  • result (bound string) - the variable which will have the resulting data uri bound to it
  • result-blob (bound Blob) - the variable which will have the resulting data as a Blob object
  • crop (bound boolean) - scope variable that must be set to true when the image is ready to be cropped

Example markup

<image-crop			 
 data-height="200"
 data-width="150"
 data-shape="square"
 data-step="imageCropStep"
 src="imgSrc"
 data-result="result"
 data-result-blob="resultBlob"
 crop="initCrop"
 padding="250"
 max-size="1024"
></image-crop>	

See a standalone working example

Working example on JSBin

Step 1. Choose image, drag to move and drag corner handle to zoom

Choose image

Step 2. Produces a result as a base64-encoded data uri

Choose image

angular-image-crop's People

Contributors

andyshora avatar demarchisd avatar mfrederickson avatar

Watchers

 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.