Skip to content

Commit 65e0036

Browse files
committed
Some very basic api docs
1 parent 084ff3a commit 65e0036

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,45 @@ See [caniuse.com/canvas](http://caniuse.com/canvas)
5050

5151
## API
5252

53-
The API is not yet finalized. Look at the code and expect changes.
53+
The API is not yet finalized. Look at the code for details and expect changes.
54+
55+
### SmartCrop.crop(image, options, callback)
56+
Crop image using options and call callback(result) when done.
57+
58+
**image:** anything ctx.drawImage() accepts, usually HTMLImageElement, HTMLCanvasElement or HTMLVideoElement
59+
60+
**options:** see cropOptions
61+
62+
**callback:** function(cropResult)
63+
64+
### cropOptions
65+
66+
**debug:** if true, cropResults will contain a debugCanvas
67+
68+
**minScale:** minimal scale of the crop rect, set to 1.0 to prevent smaller than necessary crops (lowers the risk of chopping things off).
69+
70+
**width:** width of the crop you want to use.
71+
72+
**height:** height of the crop you want to use.
73+
74+
There are many more (for now undocumented) options available. Check the [source](smartcrop.js#L32) and know that they might change in the future.
75+
76+
### cropResult
77+
```javascript
78+
{
79+
topCrop: crop,
80+
crops: [crop]
81+
}
82+
```
83+
### crop
84+
```javascript
85+
{
86+
x: 1,
87+
y: 1,
88+
width: 1,
89+
height: 1
90+
}
91+
```
5492

5593
## Tests
5694

0 commit comments

Comments
 (0)