@@ -465,12 +465,12 @@ public function resizeToShortSide($max_short, $allow_enlarge = false)
465
465
{
466
466
if ($ this ->getSourceHeight () < $ this ->getSourceWidth ()) {
467
467
$ ratio = $ max_short / $ this ->getSourceHeight ();
468
- $ long = (int ) ($ this ->getSourceWidth () * $ ratio );
468
+ $ long = (int ) round ($ this ->getSourceWidth () * $ ratio );
469
469
470
470
$ this ->resize ($ long , $ max_short , $ allow_enlarge );
471
471
} else {
472
472
$ ratio = $ max_short / $ this ->getSourceWidth ();
473
- $ long = (int ) ($ this ->getSourceHeight () * $ ratio );
473
+ $ long = (int ) round ($ this ->getSourceHeight () * $ ratio );
474
474
475
475
$ this ->resize ($ max_short , $ long , $ allow_enlarge );
476
476
}
@@ -489,12 +489,12 @@ public function resizeToLongSide($max_long, $allow_enlarge = false)
489
489
{
490
490
if ($ this ->getSourceHeight () > $ this ->getSourceWidth ()) {
491
491
$ ratio = $ max_long / $ this ->getSourceHeight ();
492
- $ short = (int ) ($ this ->getSourceWidth () * $ ratio );
492
+ $ short = (int ) round ($ this ->getSourceWidth () * $ ratio );
493
493
494
494
$ this ->resize ($ short , $ max_long , $ allow_enlarge );
495
495
} else {
496
496
$ ratio = $ max_long / $ this ->getSourceWidth ();
497
- $ short = (int ) ($ this ->getSourceHeight () * $ ratio );
497
+ $ short = (int ) round ($ this ->getSourceHeight () * $ ratio );
498
498
499
499
$ this ->resize ($ max_long , $ short , $ allow_enlarge );
500
500
}
@@ -512,7 +512,7 @@ public function resizeToLongSide($max_long, $allow_enlarge = false)
512
512
public function resizeToHeight ($ height , $ allow_enlarge = false )
513
513
{
514
514
$ ratio = $ height / $ this ->getSourceHeight ();
515
- $ width = (int ) ($ this ->getSourceWidth () * $ ratio );
515
+ $ width = (int ) round ($ this ->getSourceWidth () * $ ratio );
516
516
517
517
$ this ->resize ($ width , $ height , $ allow_enlarge );
518
518
@@ -529,7 +529,7 @@ public function resizeToHeight($height, $allow_enlarge = false)
529
529
public function resizeToWidth ($ width , $ allow_enlarge = false )
530
530
{
531
531
$ ratio = $ width / $ this ->getSourceWidth ();
532
- $ height = (int ) ($ this ->getSourceHeight () * $ ratio );
532
+ $ height = (int ) round ($ this ->getSourceHeight () * $ ratio );
533
533
534
534
$ this ->resize ($ width , $ height , $ allow_enlarge );
535
535
@@ -552,11 +552,11 @@ public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false)
552
552
553
553
$ ratio = $ this ->getSourceHeight () / $ this ->getSourceWidth ();
554
554
$ width = $ max_width ;
555
- $ height = (int ) ($ width * $ ratio );
555
+ $ height = (int ) round ($ width * $ ratio );
556
556
557
557
if ($ height > $ max_height ) {
558
558
$ height = $ max_height ;
559
- $ width = (int ) ($ height / $ ratio );
559
+ $ width = (int ) round ($ height / $ ratio );
560
560
}
561
561
562
562
return $ this ->resize ($ width , $ height , $ allow_enlarge );
@@ -570,8 +570,8 @@ public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false)
570
570
*/
571
571
public function scale ($ scale )
572
572
{
573
- $ width = (int ) ($ this ->getSourceWidth () * $ scale / 100 );
574
- $ height = (int ) ($ this ->getSourceHeight () * $ scale / 100 );
573
+ $ width = (int ) round ($ this ->getSourceWidth () * $ scale / 100 );
574
+ $ height = (int ) round ($ this ->getSourceHeight () * $ scale / 100 );
575
575
576
576
$ this ->resize ($ width , $ height , true );
577
577
@@ -642,7 +642,7 @@ public function crop($width, $height, $allow_enlarge = false, $position = self::
642
642
if ($ ratio_dest < $ ratio_source ) {
643
643
$ this ->resizeToHeight ($ height , $ allow_enlarge );
644
644
645
- $ excess_width = (int ) (($ this ->getDestWidth () - $ width ) * $ this ->getSourceWidth () / $ this ->getDestWidth ());
645
+ $ excess_width = (int ) round (($ this ->getDestWidth () - $ width ) * $ this ->getSourceWidth () / $ this ->getDestWidth ());
646
646
647
647
$ this ->source_w = $ this ->getSourceWidth () - $ excess_width ;
648
648
$ this ->source_x = $ this ->getCropPosition ($ excess_width , $ position );
@@ -651,7 +651,7 @@ public function crop($width, $height, $allow_enlarge = false, $position = self::
651
651
} else {
652
652
$ this ->resizeToWidth ($ width , $ allow_enlarge );
653
653
654
- $ excess_height = (int ) (($ this ->getDestHeight () - $ height ) * $ this ->getSourceHeight () / $ this ->getDestHeight ());
654
+ $ excess_height = (int ) round (($ this ->getDestHeight () - $ height ) * $ this ->getSourceHeight () / $ this ->getDestHeight ());
655
655
656
656
$ this ->source_h = $ this ->getSourceHeight () - $ excess_height ;
657
657
$ this ->source_y = $ this ->getCropPosition ($ excess_height , $ position );
@@ -758,7 +758,7 @@ protected function getCropPosition($expectedSize, $position = self::CROPCENTER)
758
758
$ size = $ expectedSize / 4 ;
759
759
break ;
760
760
}
761
- return (int ) $ size ;
761
+ return (int ) round ( $ size) ;
762
762
}
763
763
764
764
/**
0 commit comments