@@ -83,7 +83,7 @@ SmartCrop.crop = function(image, options, callback){
83
83
scale = min ( image . width / options . width , image . height / options . height ) ;
84
84
options . cropWidth = ~ ~ ( options . width * scale ) ;
85
85
options . cropHeight = ~ ~ ( options . height * scale ) ;
86
- // img = 100x100, width = 95x95, scale = 100/95, 1/scale > min
86
+ // img = 100x100, width = 95x95, scale = 100/95, 1/scale > min
87
87
// don't set minscale smaller than 1/scale
88
88
// -> don't pick crops that need upscaling
89
89
options . minScale = min ( options . maxScale || SmartCrop . DEFAULTS . maxScale , max ( 1 / scale , ( options . minScale || SmartCrop . DEFAULTS . minScale ) ) ) ;
@@ -121,8 +121,7 @@ SmartCrop.isAvailable = function(options){
121
121
try {
122
122
var s = new this ( options ) ,
123
123
c = s . canvas ( 16 , 16 ) ;
124
- if ( typeof c . getContext !== 'function' ) return false ;
125
- return true ;
124
+ return typeof c . getContext === 'function' ;
126
125
}
127
126
catch ( e ) {
128
127
return false ;
@@ -305,7 +304,7 @@ SmartCrop.prototype = {
305
304
topCrop = crop ;
306
305
topScore = crop . score . total ;
307
306
}
308
-
307
+
309
308
}
310
309
311
310
result . crops = crops ;
@@ -314,23 +313,21 @@ SmartCrop.prototype = {
314
313
if ( options . debug && topCrop ) {
315
314
ctx . fillStyle = 'rgba(255, 0, 0, 0.1)' ;
316
315
ctx . fillRect ( topCrop . x , topCrop . y , topCrop . width , topCrop . height ) ;
317
- if ( true ) {
318
- for ( var y = 0 ; y < output . height ; y ++ ) {
319
- for ( var x = 0 ; x < output . width ; x ++ ) {
320
- var p = ( y * output . width + x ) * 4 ;
321
- var importance = this . importance ( topCrop , x , y ) ;
322
- if ( importance > 0 ) {
323
- output . data [ p + 1 ] += importance * 32 ;
324
- }
316
+ for ( var y = 0 ; y < output . height ; y ++ ) {
317
+ for ( var x = 0 ; x < output . width ; x ++ ) {
318
+ var p = ( y * output . width + x ) * 4 ;
319
+ var importance = this . importance ( topCrop , x , y ) ;
320
+ if ( importance > 0 ) {
321
+ output . data [ p + 1 ] += importance * 32 ;
322
+ }
325
323
326
- if ( importance < 0 ) {
327
- output . data [ p ] += importance * - 64 ;
328
- }
329
- output . data [ p + 3 ] = 255 ;
324
+ if ( importance < 0 ) {
325
+ output . data [ p ] += importance * - 64 ;
330
326
}
327
+ output . data [ p + 3 ] = 255 ;
331
328
}
332
- ctx . putImageData ( output , 0 , 0 ) ;
333
329
}
330
+ ctx . putImageData ( output , 0 , 0 ) ;
334
331
ctx . strokeStyle = 'rgba(255, 0, 0, 0.8)' ;
335
332
ctx . strokeRect ( topCrop . x , topCrop . y , topCrop . width , topCrop . height ) ;
336
333
result . debugCanvas = canvas ;
@@ -381,11 +378,6 @@ function saturation(r, g, b){
381
378
return l > 0.5 ? d / ( 2 - maximum - minumum ) : d / ( maximum + minumum ) ;
382
379
}
383
380
384
-
385
-
386
-
387
-
388
-
389
381
// amd
390
382
if ( typeof define !== 'undefined' && define . amd ) define ( function ( ) { return SmartCrop ; } ) ;
391
383
//common js
0 commit comments