Plugins gratuits pour le framework JavaScript Mootools 1.2 |
Français

<< BACK TO HOME

ByCropper - Image cropper script

What is ByCropper?

ByCropper is a plugin for Mootools 1.2 which allow you to crop image dynamically, and send coordinates et size informations on a HTML form.

Features

  • Horizontal and/or vertical image cropping
  • Can force image original aspect ratio.
  • Can use customized image crop aspect ratio.
  • Can force strict image crop aspect ratio.
  • Possibility to change image crop aspect ratio on-the-fly.
  • Possibility to set a minimum height and/or width.
  • Possibility to set a maximum height and/or width.
  • Possibility to customize the border image.
  • Possibility to customize than mask color and opacity.

Usage

HTML

  1. <img src="image.jpg" id="bycropper" />

Javascript

  1. var myCropper = new ByCropper(picture, form, options);

Picture

ID of image to crop.

Form

ID of the form where to put crop informations (must contains fields with these names : "x", "y", "w" and "h").

Options

Option Type Default Description
keepRatio bool false If true, turn on aspect ratio.
ratio array [0, 0] Set the aspect ratio to apply. ([2, 1], [4, 3], [16, 9] ...)
If [0, 0], original aspect ratio will be used.
minWidth int 40 Minimum crop width.
minHeight int 40 Minimum crop height.
maxWidth int 0 Maximum crop width. 0 if no max.
maxHeight int 0 Maximum crop height. 0 if no max.
borderPath string '.' Relative or absolute URI to folder that contains border images.
maskColor string '#000000' Mask color, hexadecimal format. Default is black.
maskOpacity float 0.7 Mask opacity, between 0 (transparent) and 1 (opaque).

Public method

The method myCropper.changeRatio(ratio) can be called to set a new aspect ratio.

Requirements

ByCropper is written for Mootools v1.2

It requires these modules (and their dependencies):

  • Element.Dimensions
  • Element.Event
  • Element.Style
  • Class.Extras

Participate

Donate

If you like this script, and want to participate, you can send some money. You can give anything you want by clicking here (and you can give nothing by NOT clicking here ^^):

Get it!

How much I need to pay to get it?

Nothing! It's totally free. You can download it, modify it and use it in any commercial project as long as you respect the license. It's Open Source !

Download

You can use these two border images:

License

ByCropper by ByScripts is licensed under a Open Source MIT License.

Examples

Example 1: Default options

HTML

  1. <img src="eiffeltower.jpg" id="bycropper" />

Javascript

  1. var myCropper = new ByCropper();

Output

Change strict ratio to: Ratio = 4/3 | Ratio = 16/9 | Ratio = 2/3

Change non-strict ratio to: Ratio = 4/3 | Ratio = 16/9 | Ratio = 2/3

Set special ratio: Ratio = Picture | Ratio = Default | No Ratio

Example 2: Color and Opacity customization, min/max size

HTML

  1. <img src="eiffeltower.jpg" id="bycropper_custom" />

Javascript

  1. myCropperCustom = new ByCropper('bycropper_custom', null, {
  2. minWidth: 190,
  3. maxWidth: 380,
  4. minHeight: 110,
  5. maxHeight: 220,
  6. maskColor: "#203060",
  7. maskOpacity: 0.96
  8. });

Output

Coming Soon ...

A PHP script processing the image will be added shortly...