⬆️ ⬇️

Cropping pictures using jQuery

Cropping photos is now in demand, because any community involves the communication of living people. And communicating with the other person is easier “knowing him in person”.



I had my own requirements for the control that will produce framing. Looking for the perfect ready-made solution, I did not find it and decided to write my own.



Requirements are:

1. Icons for which you need to pull in order to change a block should be large.

2. The part of the image that is cut must be original, and the fact that it is formed translucently covered.

')

Type of framing



The script uses the jQuery library. The control itself is made as a jQuery plugin.

You can see the EXAMPLE in work , there is more about the plugin.



The interface of the plugin is as follows:



// Creates a framing control structure in the specified block element

$ (element) .CropImageCreate (src, src_width, src_height, min_width, min_height, proportion, options);



// Returns data about the cropped image as an object {src, left, top, width, height}

$ (element) .CropImageGetData ());



PS Of the ready-made scripts that I found in my opinion the best is imgAreaSelect .

Source: https://habr.com/ru/post/36588/



All Articles