Giter Site home page Giter Site logo

mean-crop's Introduction

Ready to be used!!

The repository contains

  • Directive using JCrop to crop images using a crosshair on Angular end & then send data back to the server end to save the cropped image.
  • Directive using JWindowCrop to crop images using a selection window(Simalar to Facebook) on Angular end & then send data back to the server end to save the cropped image.

Requirements

You need to have ImageMagick installed, otherwise you will get weird errors.

Installation

Install Package:

$ mean install mean-crop

Usage

What's in this package:

  • Directives to crop images using crosshair crop & selection crop.
  • Factory method to crop & save the image wherever needed. Factory method accepts the following arguments:
    • coords: co-ordinated of the cropped region relative to the actual image.
    • imgSrc: Source path of the actual image. This path gets converted into absolute filepath while cropping on the server side. packagePath & convertImgsrc are helpers to convert this path into absolute filepath.
    • width: Target width for the image.
    • height: Target width for the image.
    • packagePath(optional): If the image being cropped resides inside a package, then this attribute should define the relative path to package directory(from mean).e.g., if we trying to crop crop/assets/img/logo.png & this file actually resides at /Users/piyuesh23/htdocs/mean/packages/contrib/crop/public/assets/img/logo.png, the packagePath should be packages/contrib. convertImgsrc should be set to true, if we setting a value for packagePath.
    • destDir: Relative directory path from mean root installation where the cropped image should be saved.
    • convertImgsrc(optional):
      • true: will look for image defined in imgSrc at config.root + '/' + packagePath + '/' + packageName + '/public' + {imgSrc - packageName} while trying to crop it.
      • false/empty: will look for image defined in imgSrc at config.root + '/' + imgSrc while trying to crop it.

Examples

  • Directives

    • jWindowCrop

          <div class="" data-ng-controller="MeanCropController">
            <div class="example-container">
              <mean-window-crop target-width="100" target-height="100" img-src="'crop/assets/img/logo.png'" dest-dir="'packages/images/thumbs'" package-path="'packages/contrib'" convert-imgsrc="true"></mean-window-crop>
              <button class="btn btn-success" data-ng-click="crop()">Crop</button>
            </div>
          </div>
    • jCrop

          <div class="" data-ng-controller="MeanCropController">
            <div class="example-container">
              <mean-crop target-width="100" target-height="100" img-src="'crop/assets/img/logo.png'" dest-dir="'packages/images/thumbs'" package-path="'packages/contrib'" convert-imgsrc="true"></mean-crop>
              <button class="btn btn-success" data-ng-click="crop()">Crop</button>
            </div>
          </div>
  • Controller

      'use strict';
      angular.module('mean.crop').controller('MeanCropController', ['$rootScope', '$rootScope', 'Global', 'MeanCrop',
        function($scope, $rootScope, Global, MeanCrop) {
          $scope.global = Global;
          $scope.crop = function() {
            MeanCrop.cropImage(JSON.stringify($rootScope.coords), $rootScope.imgSrc, $rootScope.targetWidth, $rootScope.targetHeight, $rootScope.packagePath, $rootScope.convertImgsrc, $rootScope.destDir)
              .success(function(data) {
                console.log(data);
              });
          };
        }
      ]);

Demo

  • http://localhost:3000/#!/meanCrop/example - Examples of both the directives listed down here.
  • Select the area that you want to crop & click on crop button.
  • Browse to packages/images/thumbs//logo.png to check the cropped selection.

mean-crop's People

Contributors

piyuesh23 avatar liorkesos avatar

Watchers

 avatar James Cloos 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.