Gathering detailed insights and metrics for dnm-smartcroppr
Gathering detailed insights and metrics for dnm-smartcroppr
Gathering detailed insights and metrics for dnm-smartcroppr
Gathering detailed insights and metrics for dnm-smartcroppr
Easy to use JS cropper based on dnm-croppr (fork of Croppr.js) with smartcrop features of smartcrop.js.
npm install dnm-smartcroppr
Typescript
Module System
Node Version
NPM Version
75.4
Supply Chain
98.5
Quality
82.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
37 Commits
1 Branches
2 Contributors
Updated on Dec 22, 2022
Minified
Minified + Gzipped
Latest Version
1.4.2
Package Id
dnm-smartcroppr@1.4.2
Unpacked Size
154.35 kB
Size
37.25 kB
File Count
13
NPM Version
8.1.2
Node Version
16.13.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
dnm-smartcroppr is compatible with all options and methods of dnm-croppr.
Via NPM:
1npm install dnm-smartcroppr -—save
1// ES6 import - JS + CSS 2import SmartCroppr from 'dnm-smartcroppr';
Via script tag:
1<link href="path/to/dnm-smartcroppr.min.css" rel="stylesheet"/> 2<script src="path/to/dnm-smartcroppr.min.js"></script>
In your HTML document:
1<img src="path/to/image.jpg" id="croppr"/>
In your JavaScript file:
1var cropInstance = new SmartCroppr('#croppr', { 2 // ...options 3 returnMode: "real", 4 responsive: true, 5 aspectRatio: 1, 6 preview: "#cropPreview", 7 smartcrop: true, 8 smartOptions: { 9 minWidth: 500, 10 //minHeight will automatically be set to 500 because aspectRatio is 1 11 minHeight: 500, 12 onSmartCropDone: data => { 13 console.log(data) 14 } 15 }, 16 onInitialize: (instance, mediaNode) => { console.log(instance, mediaNode) }, 17 onCropEnd: data => { console.log(data) }, 18 onCropStart: (data) => { console.log(data) }, 19 onCropMove: data => { console.log(data) } 20});
All options in dnm-croppr docs #Options → are compatible with dnm-smartcroppr.
dnm-smartcroppr is optimized to work with ratios. Set aspectRatio, and optionally maxAspectRatio to find the best crop region for smartcrop.js.
There is only these additional options for now :
If false
, smartcrop is deactivated. Default value is true
.
Array
custom options for smartcrop. Default value is null
. In this case, dnm-smartcroppr is able to define these different options with basic options of dnm-croppr.
This is the different entries of smartOptions (all optionnal) :
Minimum width for smartcrop. Crop width will not be inferior to this value. Default is null
.
Minimum height for smartcrop. Crop height will not be inferior to this value. Default is null
.
Minimum scale for smartcrop. Default is null
.
Note: If minScale is defined, minWidth and minHeight are ignored. If minScale is null
, minWidth and / or minHeight will define minScale relatively to source image dimensions.
If minWidth is defined but minHeight is null
, minHeight will be calculated with aspectRatio.
When minScale is calculated with minWidth and minHeight, it can be very small. To avoid to crop big images too much, you can use minScaleTreshold, and minScale will be >= to minScaleTreshold. Default is 0.5
.
If you don't want to constrain aspectRatio and / or maxAspectRatio of dnp-croppr, you can add ratios in smartOptions, to automatically width and height of the smart crop. Default are null
.
A callback function that is called when smartcrop is done. Default value is null
.
1onSmartCropDone: function(data) { 2 console.log(data.x, data.y, data.width, data.height); 3}
All methods in dnm-croppr docs #Methods → are compatible with dnm-smartcroppr.
Modify smartcrop. smartOptions
has the same structure as in the Options doc. If crop
is false, setBestCrop() will only calculate the best crop without cropping the image.
1var smartOptions = { 2 aspectRatio: 1, 3 maxAspectRatio: 2, 4 minScale: 0.5, 5 onSmartCropDone: data => { 6 console.log(data.x, data.y, data.width, data.height); 7 } 8}; 9 10cropInstance.setBestCrop(smartOptions, true);
Note: You can access the smart cropping informations with cropperInstance.smartCropData.
Changes the image src. Returns the Croppr instance and media node. If smartcrop
is set to false, crop region will not be recalculated. Default value is true.
Changes the video src. Returns the Croppr instance and media node. If smartcrop
is set to false, crop region will not be recalculated. Default value is true.
Changes the image or video src (depending on mediaType value). Returns the Croppr instance and media node. If smartcrop
is set to false, crop region will not be recalculated. Default value is true.
Thanks to original author of Croppr.js (James Ooi) and smartcrop.js (Jonas Wagner). Released under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
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