Code Duplication    Length = 21-21 lines in 2 locations

ecrire/inc/filtres_images_lib_mini.php 2 locations

@@ 1451-1471 (lines=21) @@
1448
 * @param int $maxHeight Hauteur maximum souhaitée
1449
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1450
 **/
1451
function _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1452
	$ratioWidth = $srcWidth / $maxWidth;
1453
	$ratioHeight = $srcHeight / $maxHeight;
1454
1455
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1456
		$destWidth = $srcWidth;
1457
		$destHeight = $srcHeight;
1458
	} elseif ($ratioWidth < $ratioHeight) {
1459
		$destWidth = $srcWidth / $ratioHeight;
1460
		$destHeight = $maxHeight;
1461
	} else {
1462
		$destWidth = $maxWidth;
1463
		$destHeight = $srcHeight / $ratioWidth;
1464
	}
1465
1466
	return array(
1467
		ceil($destWidth),
1468
		ceil($destHeight),
1469
		max($ratioWidth, $ratioHeight)
1470
	);
1471
}
1472
1473
/**
1474
 * Réduire des dimensions en respectant un ratio sur la plus petite dimension
@@ 1489-1509 (lines=21) @@
1486
 * @param int $maxHeight Hauteur maximum souhaitée
1487
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1488
 **/
1489
function ratio_passe_partout($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1490
	$ratioWidth = $srcWidth / $maxWidth;
1491
	$ratioHeight = $srcHeight / $maxHeight;
1492
1493
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1494
		$destWidth = $srcWidth;
1495
		$destHeight = $srcHeight;
1496
	} elseif ($ratioWidth > $ratioHeight) {
1497
		$destWidth = $srcWidth / $ratioHeight;
1498
		$destHeight = $maxHeight;
1499
	} else {
1500
		$destWidth = $maxWidth;
1501
		$destHeight = $srcHeight / $ratioWidth;
1502
	}
1503
1504
	return array(
1505
		ceil($destWidth),
1506
		ceil($destHeight),
1507
		min($ratioWidth, $ratioHeight)
1508
	);
1509
}
1510
1511
1512
/**