Gathering detailed insights and metrics for svelte-easy-crop
Gathering detailed insights and metrics for svelte-easy-crop
Gathering detailed insights and metrics for svelte-easy-crop
Gathering detailed insights and metrics for svelte-easy-crop
npm install svelte-easy-crop
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
198 Stars
64 Commits
31 Forks
5 Watching
2 Branches
9 Contributors
Updated on 19 Nov 2024
TypeScript (36.98%)
JavaScript (31.38%)
Svelte (30.76%)
HTML (0.88%)
Cumulative downloads
Total Downloads
Last day
36.1%
904
Compared to previous day
Last week
-42.5%
3,875
Compared to previous week
Last month
46.8%
18,993
Compared to previous month
Last year
67%
142,607
Compared to previous year
1
1
20
A Svelte component to crop images with easy interactions
This is a rewrite of react-easy-crop
(https://github.com/valentinh/react-easy-crop).
1yarn add svelte-easy-crop
or
1npm install svelte-easy-crop --save
The Cropper is styled with
position: absolute
to take the full space of its parent. Thus, you need to wrap it with an element that usesposition: relative
or the Cropper will fill the whole page.
1<script> 2 import Cropper from 'svelte-easy-crop' 3 4 let image = '/images/dog.jpeg' 5 let crop = { x: 0, y: 0 } 6 let zoom = 1 7</script> 8 9<Cropper 10 {image} 11 bind:crop 12 bind:zoom 13 on:cropcomplete={e => console.log(e.detail)} 14/>
Prop | Type | Required | Description |
---|---|---|---|
image | string | ✓ | The image to be cropped. |
crop | { x: number, y: number } | ✓ | Position of the image. { x: 0, y: 0 } will center the image under the cropper. |
zoom | number | Zoom of the image between minZoom and maxZoom . Defaults to 1. | |
aspect | number | Aspect of the cropper. The value is the ratio between its width and its height. The default value is 4/3 | |
minZoom | number | Minimum zoom of the image. Defaults to 1. | |
maxZoom | number | Maximum zoom of the image. Defaults to 3. | |
cropShape | 'rect' | 'round' | Shape of the crop area. Defaults to 'rect'. | |
cropSize | { width: number, height: number } | Size of the crop area (in pixels). If you don't provide it, it will be computed automatically using the aspect prop and the image size. | |
showGrid | boolean | Whether to show or not the grid (third-lines). Defaults to true . | |
zoomSpeed | number | Multiplies the value by which the zoom changes. Defaults to 1. | |
crossOrigin | string | Allows setting the crossOrigin attribute on the image. | |
restrictPosition | boolean | Whether the position of the image should be restricted to the boundaries of the cropper. Useful setting in case of zoom < 1 or if the cropper should preserve all image content while forcing a specific aspect ratio for image throughout the application. Example: https://codesandbox.io/s/1rmqky233q. |
This event is the one you should use to save the cropped area of the image. The detail
property is an object with 2 values:
percent
: coordinates and dimensions of the cropped area in percentage of the image dimensionpixels
: coordinates and dimensions of the cropped area in pixels.Both arguments have the following shape:
1const area = { 2 x: number, // x/y are the coordinates of the top/left corner of the cropped area 3 y: number, 4 width: number, // width of the cropped area 5 height: number, // height of the cropped area 6}
1yarn 2yarn dev
Now, open http://localhost:5000
and start hacking!
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 6/24 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
21 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More