Code Duplication    Length = 21-21 lines in 2 locations

ecrire/inc/filtres_images_lib_mini.php 2 locations

@@ 1331-1351 (lines=21) @@
1328
 * @param int $maxHeight Hauteur maximum souhaitée
1329
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1330
 **/
1331
function _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1332
	$ratioWidth = $srcWidth / $maxWidth;
1333
	$ratioHeight = $srcHeight / $maxHeight;
1334
1335
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1336
		$destWidth = $srcWidth;
1337
		$destHeight = $srcHeight;
1338
	} elseif ($ratioWidth < $ratioHeight) {
1339
		$destWidth = $srcWidth / $ratioHeight;
1340
		$destHeight = $maxHeight;
1341
	} else {
1342
		$destWidth = $maxWidth;
1343
		$destHeight = $srcHeight / $ratioWidth;
1344
	}
1345
1346
	return array(
1347
		ceil($destWidth),
1348
		ceil($destHeight),
1349
		max($ratioWidth, $ratioHeight)
1350
	);
1351
}
1352
1353
/**
1354
 * Réduire des dimensions en respectant un ratio sur la plus petite dimension
@@ 1369-1389 (lines=21) @@
1366
 * @param int $maxHeight Hauteur maximum souhaitée
1367
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1368
 **/
1369
function ratio_passe_partout($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1370
	$ratioWidth = $srcWidth / $maxWidth;
1371
	$ratioHeight = $srcHeight / $maxHeight;
1372
1373
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1374
		$destWidth = $srcWidth;
1375
		$destHeight = $srcHeight;
1376
	} elseif ($ratioWidth > $ratioHeight) {
1377
		$destWidth = $srcWidth / $ratioHeight;
1378
		$destHeight = $maxHeight;
1379
	} else {
1380
		$destWidth = $maxWidth;
1381
		$destHeight = $srcHeight / $ratioWidth;
1382
	}
1383
1384
	return array(
1385
		ceil($destWidth),
1386
		ceil($destHeight),
1387
		min($ratioWidth, $ratioHeight)
1388
	);
1389
}
1390
1391
1392
/**