npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-image-cropper

v1.2.0

Published

AngularJS directive for cropping images (responsive|touch).

Downloads

230

Readme

travis codecov version downloads MIT License semantic-release Commitizen friendly

Angular image cropper

Live example

To see a live example, go to the demo's page.

Description

Angular image cropper is inspired of the popular Guillotine jQuery plugin that allows to drag, zoom or rotate an image to select a cropping area. Like selecting the display area of a profile picture or avatar.

  • Responsive: The window (or selection area) is fully responsive (fluid)
  • Touch support: Dragging the image also works on touch devices
  • API: Provide an API to do more action with code
  • No needs of jQuery: Written in pure javascript

Installation

Using NPM

npm install angular-image-cropper

Using Bower (not recommended)

bower install https://unpkg.com/angular-image-cropper/bower.zip

Or if you want to install a specific version (e.g: for 1.1.4):

bower install https://unpkg.com/[email protected]/bower.zip --save

Usage

Load the required files

Using modules

Just require the module when you declare your module's dependencies:

var angular = require('angular');
angular
  .module('myApp', [require('angular-image-cropper')])
  .controller(/*...*/);

Using script tags

Just import the angular-image-cropper javascript file in your index.html:

<script src="/path/to/angular-image-cropper.js"></script>

Add the module as dependency to your main application module like this:

angular.module('myApp', ['imageCropper']);

The directive

<image-cropper image-url="myImageUrlOrBase64"
  width="640"
  height="480"
  show-controls="true"
  fit-on-init="false"
  center-on-init="true"
  api="getApiFunction"
  crop-callback="myCallbackFunction"
  check-cross-origin="false"
  zoom-step="0.1"
  action-labels="myButtonLabelsObject"
></image-cropper>

Options

Angular image cropper comes with some options to simplify your development:

  • image-url string Source image that will be cropped, can be an URL or base64
  • width string Width of the cropped image
  • height string Height of the cropped image
  • zoom-step string Zoom step
  • fit-on-init boolean Fit the image on cropper initialization (keep the ratio)
  • center-on-init boolean Center the image on cropper initialization
  • show-controls boolean Display or not the control buttons (true by default)
  • check-cross-origin boolean Enable cross origin or not
  • crop-callback function Function executed with base64 cropped image as argument when when crop control is clicked
vm.updateResultImage = function(base64) {
  vm.resultImage = base64;
  $scope.$apply(); // Apply the changes.
};
  • api function Function executed with cropper's API as argument
  • action-labels object Give you the ability to customize button labels by passing an object like
vm.myButtonLabels = {
  rotateLeft: ' (rotate left) ',
  rotateRight: ' (rotate right) ',
  zoomIn: ' (zoomIn) ',
  zoomOut: ' (zoomOut) ',
  fit: ' (fit) ',
  crop: ' <span class="fa fa-crop">[crop]</span> ' // You can pass html too.
}

Api

Angular image cropper gives you access to the api, you can see an example here:

// Cropper API available when image is ready.
vm.getCropperApi = function(api) {
  api.zoomIn(3);
  api.zoomOut(2);
  api.rotate(270);
  api.fit();
  vm.resultImage = api.crop();
};
  • crop function return the cropped image in base64
  • fit function fit the image to the wrapper dimensions (keep the ratio)
  • rotate function Apply the rotation with degrees given, should be a modulo of 90 (90, 180, 270, 360), can be negative
  • zoomIn function Apply the zoomIn given
  • zoomOut function Apply the zoomOut given
  • remove function Remove the cropper

License

The MIT License (MIT)