Code Duplication    Length = 21-21 lines in 2 locations

ecrire/inc/filtres_images_lib_mini.php 2 locations

@@ 1462-1482 (lines=21) @@
1459
 * @param int $maxHeight Hauteur maximum souhaitée
1460
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1461
 **/
1462
function _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1463
	$ratioWidth = $srcWidth / $maxWidth;
1464
	$ratioHeight = $srcHeight / $maxHeight;
1465
1466
	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1467
		$destWidth = $srcWidth;
1468
		$destHeight = $srcHeight;
1469
	} elseif ($ratioWidth < $ratioHeight) {
1470
		$destWidth = $srcWidth / $ratioHeight;
1471
		$destHeight = $maxHeight;
1472
	} else {
1473
		$destWidth = $maxWidth;
1474
		$destHeight = $srcHeight / $ratioWidth;
1475
	}
1476
1477
	return array(
1478
		intval(round($destWidth)),
1479
		intval(round($destHeight)),
1480
		max($ratioWidth, $ratioHeight)
1481
	);
1482
}
1483
1484
/**
1485
 * Réduire des dimensions en respectant un ratio sur la plus petite dimension
@@ 1500-1520 (lines=21) @@
1497
 * @param int $maxHeight Hauteur maximum souhaitée
1498
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1499
 **/
1500
function ratio_passe_partout($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1501
	$ratioWidth = $srcWidth / $maxWidth;
1502
	$ratioHeight = $srcHeight / $maxHeight;
1503
1504
	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1505
		$destWidth = $srcWidth;
1506
		$destHeight = $srcHeight;
1507
	} elseif ($ratioWidth > $ratioHeight) {
1508
		$destWidth = $srcWidth / $ratioHeight;
1509
		$destHeight = $maxHeight;
1510
	} else {
1511
		$destWidth = $maxWidth;
1512
		$destHeight = $srcHeight / $ratioWidth;
1513
	}
1514
1515
	return array(
1516
		intval(round($destWidth)),
1517
		intval(round($destHeight)),
1518
		min($ratioWidth, $ratioHeight)
1519
	);
1520
}
1521
1522
1523
/**