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

jr-crop

v1.1.2

Published

jr-crop ======

Downloads

6

Readme

jr-crop

A simple ionic plugin to crop your images, inspired by whatsapp and telegram.

  • Specifiy width and height of target
  • Doesn't actually scale the image, only returns a cropped version. Since the quality of images while scaling is inconsistent it's up to the developper to implement this, preferably on the server.
  • Returns a canvas element with the new cropped image.

example

Simple enough, let's get started.

Install the files: bower install jr-crop --save.

Import the static files jr-crop.js and jr-crop.css. Declare jrCrop as a dependency.

.module('myModule', ['ionic', 'jrCrop'])

Inject jr-crop.

.controller('MyController', function($jrCrop) {

Call the crop function to open a new modal where the user can crop this image. Pass in the image url and targetsize. The function will return a promise that resolves when the user is done or fails when the user cancels.

$jrCrop.crop({
    url: url,
    width: 200,
    height: 200
}).then(function(canvas) {
    // success!
    var image = canvas.toDataURL();
}, function() {
    // User canceled or couldn't load image.
});
Changing the title

Additionally you can add a title in the footer.

$jrCrop.crop({
    url: url,
    width: 200,
    height: 200,
    title: 'Move and Scale'
});
Circle mask

Add circle:true to the options to overlay the image with a circle. Note: it won't actually crop the image with a circle, just the visual representation.

$jrCrop.crop({
    url: url,
    circle: true
});
Changing default options.

Overwriting default options can be done as well.
$jrCrop.defaultOptions.template = '<div>...</div>';
$jrCrop.defaultOptions.width = 300;
$jrCrop.defaultOptions.circle = true;

Templates

Custom templates

The template can be overwritten by passing your custom HTML in the options.

$jrCrop.crop({
    url: url,
    width: 200,
    height: 200,
    template: '<div>...</div>'
});
Interpolation Markup

If you configured the expressions of interpolated strings, you can apply this to the template by replacing the markup with your custom markup.

$jrCrop.defaultOptions.template = $jrCrop.defaultOptions.template
    .replace(/{{/g, '<%')
    .replace(/}}/g, '%>');

Examples please!!

I got ya. Run bower install && npm install && npm test and visit localhost:8181. Great, now you can visit this from your phone too. It works best when packaged in cordova, as how you should use ionic anyway.

Support

Though I'm only supporting iOS, I did get reports that it's working well on Android. If it doesn't, feel free to fork and update my codebase. If you just want to leave your thoughts you can reply in the ionic forum topic.

Contributing

Open an issue or create a pull request. Please exclude the /dist files from your pull request.

Release History

  • 2015-11-13  v1.1.2   Overwrite the template through options. Documentation on defaultOptions.
  • 2015-11-12   v1.1.1   Circle mask should not be shown by default.
  • 2015-11-12   v1.1.0   Add circle option to overlay the image with a circle mask.
  • 2015-04-05   v1.0.0   Breaking: jr-crop is now its own module, import it first. Support ionic v1.0.0 release candidate. Setting options will no longer overwrite the default options.
  • 2015-01-04   v0.1.1   Customize Cancel and Choose text.
  • 2014-12-14   v0.1.0   Release on bower, move from grunt to gulp, version numbering in header. Clean up examples and test server. Place the image in the center on initializing. Add maximum scale option. Hide picture overflow in modal at bigger viewport. Add example pictures as static files rather than from url.