Cropper introduction of front-end cutting picture plugin

Source: Internet
Author: User

To introduce a very practical front end of the jquery-dependent image cutting plugin cropper.

Because the front-end can not do the cutting of the picture, so the actual need to use cropper and backstage GraphicsMagick Mutual cooperation.

First put on the Cropper URL https://fengyuanchen.github.io/cropperjs/ and GitHub address : Https://github.com/fengyuanchen/cropper 

First step: Download cropper:

  

NPM install cropper.

Part II: Introduction of dependency packages and plug-in packages:

  

<script src= "/path/to/jquery.js" ></script><!--jquery is required--><link  href= "/path/to/ Cropper.css "rel=" stylesheet "><script src="/path/to/cropper.js "></script>

The third part: The method is called in JS:

$ (' #image '). Cropper ({  16/9,  function(e) {    //  Output The result data for cropping image.     Console.log (e.x);    Console.log (E.Y);    Console.log (e.width);    Console.log (e.height);    Console.log (e.rotate);    Console.log (E.scalex);    Console.log (E.scaley);  }});

Where aspectratio refers to the aspect ratio of a picture

Only need to x,y,width,height,rotate,scalex,scaley these data to the background, the background can be based on the data for the cutting of the picture.

Use Cropper to be aware that this plugin will build some tags in the DOM, so when the picture is displayed, pay more attention to:

  

  

Cropper introduction of front-end cutting picture plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.